-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.server.js
49 lines (47 loc) · 1.2 KB
/
webpack.server.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
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const EventHooksPlugin = require("event-hooks-webpack-plugin");
const path = require("path");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const nodemon = require('nodemon');
const devMode = process.env.NODE_ENV !== "production";
let running = false;
let plugs = [
new CleanWebpackPlugin(["dist"], {
exclude: ["public"]
})
];
if (devMode) {
plugs = plugs.concat([
new EventHooksPlugin({
done: () => {
if (!running) {
running = true;
process.chdir(path.join(__dirname, "./dist"));
console.log("nodemon start...");
nodemon({
script: "server.js",
delay: 2 * 1000,
// ignore: ["public/*", "logs/*"]
});
}
}
})
]);
}
let config = merge(common, {
target: "node",
devtool: devMode ? "inline-source-map" : false,
entry: {
app: ["babel-polyfill", "./src/server.js"]
},
output: {
path: path.resolve(__dirname, "dist/"),
publicPath: "",
filename: "server.js",
chunkFilename: "[name].bundle.js"
},
plugins: plugs
});
config.optimization = {}
module.exports = config