-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
37 lines (36 loc) · 977 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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/main.js",
context: process.cwd(),
mode: "development",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
},
devServer: {
// static: {
// directory: path.join(__dirname, "dist"),
// publicPath: path.join(__dirname, "dist"),
// },
// compress: true,
// port: 3000,
// hot: true,
// historyApiFallback: true,
onBeforeSetupMiddleware: (devServer) => {
if (!devServer) throw new Error("webpack-dev-server is not available");
devServer.app.get("/success", (req, res) => {
res.json({ id: 1001 }); // status code 200
});
devServer.app.post("/error", (req, res) => {
res.sendStatus(500); // status code 500
});
},
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
inject: "head",
}),
],
};