-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.mjs
49 lines (46 loc) · 1.18 KB
/
webpack.config.mjs
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
import path from "node:path";
import webpack from "webpack";
import ShebangPlugin from "webpack-shebang-plugin";
const __dirname = import.meta.dirname;
/**
* @type {(env: { WEBPACK_BUNDLE: boolean, WEBPACK_BUILD: boolean }, options: { mode: 'development' | 'production', env: Record<string, unknown> }) => Promise<import('webpack').Configuration>}
*/
const config = async (_env, { mode }) => {
return {
entry: "./src/cli.mjs",
devtool: mode === "production" ? false : "inline-source-map",
plugins: [
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(process.env.NODE_ENV),
}),
new ShebangPlugin(),
],
module: {
rules: [
{
test: /\.m?js$/,
resolve: {
fullySpecified: false, // disable the behaviour
},
},
],
},
resolve: {
alias: {
"vscode-uri/lib/umd": path.resolve(
__dirname,
"node_modules/vscode-uri/lib/umd/index.js",
),
},
},
target: "node",
output: {
path: path.resolve(__dirname, "dist"),
filename: "cli.cjs",
library: {
type: "commonjs",
},
},
};
};
export default config;