-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
45 lines (44 loc) · 1.56 KB
/
webpack.dev.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
const { merge } = require("webpack-merge");
const webpackCommon = require("./webpack.common.config.js");
const Dotenv = require("dotenv-webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { EnvironmentPlugin } = require("webpack");
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
const fs = require("fs");
module.exports = (env) => {
const customenvfile = `env/${env.envfile}`;
const envfile = fs.existsSync(customenvfile) ? customenvfile : "env/.env.local";
console.log("Using envfile", envfile);
return merge(webpackCommon, {
mode: "development",
devtool: "source-map",
devServer: {
historyApiFallback: true,
devMiddleware: {
writeToDisk: true,
},
client: {
webSocketTransport: "ws",
},
webSocketServer: "ws",
port: 5259,
hot: true,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
},
},
plugins: [
new Dotenv({ path: envfile }),
new ReactRefreshWebpackPlugin(),
new HtmlWebpackPlugin({
publicPath: "/",
template: "./src/index.html",
}),
new EnvironmentPlugin({
ENABLE_MOCK: "",
}),
],
});
};