forked from Eceri/KR-Index
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
48 lines (46 loc) · 1.21 KB
/
webpack.dev.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
const merge = require("webpack-merge");
const common = require("./webpack.common");
const path = require("path");
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = (env) => {
return merge(common, {
mode: "development",
devtool: "eval-source-map",
devServer: {
contentBase: [
path.resolve(__dirname, "build"),
path.resolve(__dirname, "localAssets"),
],
contentBasePublicPath: ["public", "/assets"],
before(app, server) {
const chokidar = require("chokidar");
chokidar
.watch(path.resolve(__dirname, "src"))
.on("all", (event, path) => {
server.sockWrite(server.sockets, "content-changed");
});
},
hot: true,
historyApiFallback: true,
compress: true,
index: "index.html",
// proxy: {
// "/assets": {
// changeOrigin: true,
// target: "https://krindex.net",
// },
// },
},
stats: "errors-only",
plugins: environmentPicker(env),
});
};
const environmentPicker = (env) => {
// Is env defined ?
if (env) {
if (env.analyze) {
return [new BundleAnalyzerPlugin()];
}
}
};