-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.js
46 lines (42 loc) · 1.27 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
const nodeExternals = require('webpack-node-externals');
const {join} = require('path');
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
module.exports = function (options, webpack) {
const outputFolder = join(__dirname, 'dist', 'server');
const config = {
...options,
entry: [
options.entry
],
externals: [
nodeExternals({
allowlist: ['webpack/hot/poll?100'],
}),
],
plugins: [
...options.plugins,
new CleanWebpackPlugin(),
],
output: {
path: outputFolder,
filename: options.output.filename,
},
};
if (process.env.NODE_ENV !== 'production') {
const {RunScriptWebpackPlugin} = require("run-script-webpack-plugin");
config.devtool = 'eval';
config.entry.unshift('webpack/hot/poll?100');
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.WatchIgnorePlugin({
paths: [/\.js$/, /\.d\.ts$/],
}),
new RunScriptWebpackPlugin({
name: options.output.filename
})
)
} else {
config.devtool = 'source-map';
}
return config;
};