-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
73 lines (64 loc) · 1.51 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const webpack = require('webpack')
const path = require('path')
const TerserPlugin = require("terser-webpack-plugin");
const { NODE_ENV = 'development' } = process.env
const isProduction = NODE_ENV !== 'development'
const packages = require('./package.json')
module.exports = {
target: 'node',
devtool: false,
externals: [
...Object.keys(packages.dependencies || {})
],
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV,
WEBPACK_ENV: true
}),
!isProduction && new webpack.HotModuleReplacementPlugin()
].filter(Boolean),
entry: [
!isProduction && 'webpack/hot/poll?1000',
path.resolve(path.join(__dirname, './src/index'))
].filter(Boolean),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'app.bundle.js',
libraryTarget: 'commonjs2'
},
resolve: {
extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.jsx', '.ts', '.tsx', '.json'],
modules: [
path.join(__dirname, '..', 'src'),
'node_modules'
]
},
module: {
rules: [
{
// Include ts, tsx, js, and jsx files.
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
babelrc: true,
cacheDirectory: true
}
}
]
},
node: {
global: false,
__filename: false,
__dirname: false
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
keep_classnames: true,
},
}),
],
},
}