forked from liquality/hw-web-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
37 lines (34 loc) · 891 Bytes
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const path = require('path')
const cwd = process.cwd()
const pkg = require(path.join(cwd, 'package.json'))
const isProdEnv = process.env.NODE_ENV === 'production'
const isWatchEnv = process.env.WEBPACK_WATCH === 'true'
const plugins = []
module.exports = {
devtool: isProdEnv ? 'source-map' : 'eval',
entry: './src/index.ts',
mode: isProdEnv ? 'production' : 'development',
watch: isWatchEnv,
target: 'node',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: path.basename(pkg.main),
path: path.resolve(cwd, 'dist'),
libraryTarget: 'commonjs2'
},
plugins,
optimization: {
usedExports: true // TODO: how to enable tree shaking on commonjs internal and modules? tsconfig should be esnext?
}
}