forked from chrisleekr/binance-trading-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.prod.js
54 lines (51 loc) · 1.22 KB
/
webpack.config.prod.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
const path = require('path');
const fs = require('fs');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); // installed via npm
const { NODE_ENV = 'production' } = process.env;
const nodeModules = {};
fs.readdirSync('node_modules')
.filter(x => {
return ['.bin'].indexOf(x) === -1;
})
.forEach(mod => {
nodeModules[mod] = `commonjs ${mod}`;
});
module.exports = {
entry: './app/server.js',
target: 'node',
mode: NODE_ENV,
output: {
filename: 'server.js',
path: path.resolve(__dirname, 'dist')
},
devtool: '#source-map',
plugins: [
new CleanWebpackPlugin(),
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true
}),
new LodashModuleReplacementPlugin()
],
resolve: {
extensions: ['.js']
},
module: {
rules: [
{
// Transpiles ES6-8 into ES5
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/,
options: {
plugins: ['lodash'],
presets: [['@babel/env', { targets: { node: 13 } }]]
}
}
]
},
externals: nodeModules
};