-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathwebpack.config.js
More file actions
81 lines (75 loc) · 1.97 KB
/
webpack.config.js
File metadata and controls
81 lines (75 loc) · 1.97 KB
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
//@ts-check
'use strict';
const path = require('node:path');
//@ts-ignore
module.exports = (_env, argv) => {
const isProd = argv.mode === 'production';
/** @type {import('webpack').Configuration} */
const config = {
name: 'extension',
target: 'node',
entry: './src/extension.mts',
mode: isProd ? 'production' : 'development',
output: {
path: path.resolve(__dirname, "dist"),
filename: 'extension.js',
libraryTarget: 'commonjs2',
},
node: {
__dirname: false,
},
devtool: 'source-map',
externals: {
vscode: "commonjs vscode"
},
resolve: {
extensions: ['.mts', '.ts', '.mjs', '.js'],
mainFields: ['main', 'module'],
extensionAlias: {
'.mjs': ['.mts', '.mjs'], // allow imports written as ./file.mjs to resolve ./file.mts
'.js': ['.ts', '.js'], // allow imports written as ./file.js to resolve ./file.ts
},
},
module: {
rules: [{
test: /\.[cm]?ts$/,
exclude: /node_modules/,
use: [{
// configure TypeScript loader:
// * enable sources maps for end-to-end source maps
loader: 'ts-loader',
options: {
transpileOnly: true
}
}]
}, {
test: /.node$/,
loader: 'node-loader',
}]
},
optimization: {
minimize: isProd
},
stats: {
warnings: false
}
};
/** @type {import('webpack').Configuration} */
const uninstallerEsm = {
name: 'uninstaller',
target: 'node',
mode: 'production',
entry: './vscodeUninstall.mjs', // your existing file with TLA
experiments: { outputModule: true, topLevelAwait: true },
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'vscodeUninstall.mjs',
library: { type: 'module' },
chunkFormat: 'module',
clean: false,
},
devtool: false,
resolve: { extensions: ['.mjs', '.js'] },
};
return [config, uninstallerEsm];
};