-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
65 lines (63 loc) · 1.46 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
const webpack = require("webpack");
const NodemonPlugin = require("nodemon-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ProgressBarPlugin = require("progress-bar-webpack-plugin");
const NodeExternals = require("webpack-node-externals");
const AppOptions = require("./lib").loadOptions();
const DEV = process.env.NODE_ENV === "development";
module.exports = {
target: "node",
mode: DEV ? "development" : "production",
entry: [AppOptions.appIndex],
output: {
path: AppOptions.appBuild,
filename: "index.js"
},
devtool: DEV ? "eval-source-map" : AppOptions.sourceMap ? "source-map" : AppOptions.sourceMap,
node: {
__filename: false,
__dirname: false
},
optimization: {
minimize: !DEV
},
resolve: {
extensions: [".ts", ".js", ".mjs", ".node"],
alias: {
"~": AppOptions.rootPath
}
},
externals: [
/public\/library\/.+$/,
!AppOptions.buildNodeModules &&
NodeExternals({
whitelist: ["webpack/hot/signal"]
}),
"uws"
].filter(d => d),
module: {
rules: [
{
test: /\.(js|mjs|ts)$/,
use: {
loader: require.resolve("ts-loader"),
options: {
transpileOnly: true,
configFile: AppOptions.tsConfigFile
}
}
}
]
},
plugins: [
new CleanWebpackPlugin(),
new ProgressBarPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
AppOptions.nodemon &&
new NodemonPlugin({
ignore: ["*.js.map"],
nodeArgs: ["--inspect"],
verbose: true
})
].filter(d => d)
};