forked from elpete/gitlab-npm-audit-parser
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
53 lines (50 loc) · 1.32 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
// Generated using webpack-cli https://github.com/webpack/webpack-cli
const isProduction = process.env.NODE_ENV === "production";
const path = require("path");
const SheBangPlugin = require("webpack-shebang-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
const thisModule = require("./package.json");
function buildConfig(env) {
return {
entry: "./parse.js",
target: "node",
output: {
path: path.resolve(
__dirname,
path.dirname(thisModule.main) === "."
? "dist"
: path.dirname(thisModule.main)
),
filename: path.basename(thisModule.main)
},
plugins: [
new SheBangPlugin({
chmod: 0o755
}),
new ESLintPlugin({
fix: env.WEBPACK_WATCH
})
],
optimization: {
// minimize & mangle the output files (TerserPlugin w/ webpack@v5)
minimize: true,
// determine which exports are used by modules and removed unused ones
usedExports: true
},
resolve: {
extensions: [".js", ".json"]
},
externalsPresets: {
node: true // ignore node built-in modules like path, fs, etc.
}
};
}
module.exports = (env) => {
const config = buildConfig(env);
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
}
return config;
};