-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
59 lines (50 loc) · 1.47 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
49
50
51
52
53
54
55
56
57
58
59
const { merge } = require("webpack-merge"),
HtmlWebpackPlugin = require("html-webpack-plugin"),
path = require("path");
const BundleAnalyzerPlugin =
require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const common = require("./webpack.common.js");
const { nocProxyMiddlewareFactory } = require("./server/noc-proxy-middleware");
module.exports = (env) => {
const { niceorgBaseUrl = "https://www.nice.org.uk" } = env;
return merge(common(env), {
mode: "development",
devtool: "inline-source-map",
plugins: [
new BundleAnalyzerPlugin(),
new HtmlWebpackPlugin({
filename: "playground.html",
template: "server/playground.ejs",
inject: "body",
scriptLoading: "defer",
templateParameters: {
title: "NOC playground"
}
})
],
devServer: {
static: {
directory: path.join(__dirname, "dist"),
// Replicate the CDN sub folder:
publicPath: "/niceorg"
},
port: 8087,
open: ["niceorg/playground.html"],
hot: true,
setupMiddlewares: (middlewares, devServer) => {
// Allow cross origin requests for font files
devServer.app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
});
console.info(`Proxying requests to ${niceorgBaseUrl}`);
devServer.app.use(nocProxyMiddlewareFactory(niceorgBaseUrl));
return middlewares;
}
}
});
};