-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
42 lines (38 loc) · 1004 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
38
39
40
41
42
const webpack = require("webpack");
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const NodemonPlugin = require('nodemon-webpack-plugin');
const nodeEnv = process.env.NODE_ENV || "development";
const isProduction = nodeEnv !== "development";
// Common plugins
let plugins = [
new webpack.DefinePlugin({
"process.env": { NODE_ENV: JSON.stringify(nodeEnv) },
}),
new NodemonPlugin({
// Files to ignore.
ignore: ['*.js.map'],
// Extensions to watch.
ext: 'js',
}), //
];
if (!isProduction) {
plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = {
mode: nodeEnv,
devtool: "source-map",
entry: "./src/app.js",
externals: [nodeExternals()],
externalsPresets: { node: true },
plugins: plugins,
target: "node",
output: {
path: path.resolve(__dirname, "build"),
filename: "app.js",
},
resolve: {
extensions: [".js"],
modules: [path.resolve(__dirname, "node_modules")],
},
};