-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.development.babel.js
99 lines (92 loc) · 2.38 KB
/
webpack.development.babel.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import merge from "webpack-merge";
import webpack from "webpack";
import path from "path";
import DotenvWebpack from "dotenv-webpack";
import CopyPlugin from "copy-webpack-plugin";
import common from "./webpack.common.babel";
let userObject = {
firstName: "John",
lastName: "Smith",
joinedDate: "1994-06-10",
email: "[email protected]",
publicCode: "PhkLLuFfaCapAi66WPkXVm2dbDN69zR7QLWqJp2efGf",
socialSecurityNumber: "122-2227",
clue: {
bio: "Hello, World!",
country: {
name: "Philippines",
},
},
isAccountVerified: true,
workExperiences: undefined,
kycState: undefined,
};
module.exports = merge(common, {
mode: "development",
devtool: "source-map",
devServer: {
historyApiFallback: true,
compress: true,
hot: true,
host: "0.0.0.0",
port: 8080,
static: path.resolve(__dirname, "./dist/debug"),
client: {
overlay: true,
progress: true,
},
onBeforeSetupMiddleware: (devServer) => {
if (!devServer) {
throw new Error("webpack-dev-server is not defined");
}
devServer.app.get("/api", (_, res) => {
res.status(200).json({
msg: "How long is forever?",
});
});
devServer.app.get("/api/hello", (_, res) => {
res.status(200).json({
msg: "Hello, World!",
});
});
devServer.app.get("/api/me", (_, res) => {
res.status(200).json({
firstName: userObject.firstName,
lastName: userObject.lastName,
joinedDate: userObject.joinedDate,
email: userObject.email,
publicCode: userObject.publicCode,
});
});
devServer.app.get("/api/user/:id/extended", (_, res) => {
res.status(200).json(userObject);
});
devServer.app.get("/api/work-functions", (_, res) => {
res.status(200).json([
"Web Developer",
"User Experience",
"Graphic Artist",
]
);
});
},
},
stats: "normal",
output: {
path: path.resolve(__dirname, "./dist/debug/"),
},
plugins: [
new DotenvWebpack(),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "./src/assets/images/apple-touch-icon.png"),
to: path.resolve(__dirname, "./dist/debug/"),
},
],
}),
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
}),
],
});