-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
76 lines (73 loc) · 1.6 KB
/
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
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
const path = require("path")
const { EnvironmentPlugin } = require("webpack")
const TerserPlugin = require("terser-webpack-plugin")
console.log("NODE_ENV: " + process.env.NODE_ENV)
const isProdEnv = process.env.NODE_ENV === "production"
const isDevServer = process.env.WEBPACK_SERVE === "true"
const srcDir = path.resolve(__dirname, "src")
const buildDir = path.resolve(__dirname, "build")
module.exports = {
entry: {
htsd: path.resolve(srcDir, "htsd.mjs"),
},
output: {
path: buildDir,
filename: "[name].min.js",
},
mode: isProdEnv ? "production" : "development",
devtool: "source-map",
devServer: {
static: {
directory: buildDir,
},
},
resolve: {
extensions: [".js"],
},
performance: {
hints: (() => {
if (isDevServer) {
return false
}
if (isProdEnv) {
return "error"
}
return "warning"
})(),
maxAssetSize: 12.1 * 1024,
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
}),
],
},
plugins: [new EnvironmentPlugin(["npm_package_version"])],
module: {
rules: [
{
test: (f) => path.extname(f) === ".mjs" && f.startsWith(srcDir + "/"),
loader: "babel-loader",
},
{
test: /\.lazy\.css$/,
use: [
{
loader: "style-loader",
options: {
injectType: "lazyStyleTag",
},
},
{
loader: "css-loader",
options: {
sourceMap: false,
},
},
],
},
],
},
}