-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathwebpack.config.js
More file actions
78 lines (66 loc) · 2.38 KB
/
webpack.config.js
File metadata and controls
78 lines (66 loc) · 2.38 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
/*---------------------------------------------------------------------------------------------
* Minimal webpack config for VS Code extensions
* Uses ES Modules (compatible with Yarn 4, npm 11, and modern Node.js)
*--------------------------------------------------------------------------------------------*/
import path from 'path';
import { fileURLToPath } from 'url';
import ESLintPlugin from 'eslint-webpack-plugin';
// Recreate __dirname for ES Modules (not available in ESM by default)
const __dirname = path.dirname(fileURLToPath(import.meta.url));
/** @type {import('webpack').Configuration} */
export default {
// VS Code extensions run in a Node.js environment, not a browser
target: 'node',
// 'none' mode disables default optimizations (VS Code handles this)
mode: 'none',
// Entry point: where webpack starts bundling your extension
entry: './src/extension.ts',
output: {
// Output directory for the bundled extension
path: path.resolve(__dirname, 'dist'),
// Final bundle filename (must match 'main' in package.json)
filename: 'extension.js',
// Required format for VS Code extensions (CommonJS)
libraryTarget: 'commonjs2'
},
// Generate source maps for debugging (maps bundled code back to original TypeScript)
devtool: 'source-map',
externals: {
// 'vscode' module is provided by VS Code at runtime — don't bundle it
vscode: 'commonjs vscode'
// Add other native modules here if needed (e.g., 'fsevents': 'commonjs fsevents')
},
resolve: {
// File extensions webpack will look for (in order)
extensions: ['.ts', '.js']
},
module: {
rules: [
{
// Match all TypeScript files
test: /\.ts$/,
// Skip node_modules (already compiled)
exclude: /node_modules/,
use: {
loader: 'ts-loader',
// Explicitly point to your tsconfig.json (fixes ESM resolution issues)
options: { configFile: path.resolve(__dirname, 'tsconfig.json') }
}
}
]
},
plugins: [
// Lint TypeScript files during build
new ESLintPlugin({
extensions: ['.ts'],
exclude: ['node_modules', 'dist']
})
],
// Suppress known harmless warnings from vscode-languageserver-types UMD build
ignoreWarnings: [
{
module: /vscode-languageserver-types/,
message: /Critical dependency: require function is used in a way/
}
]
};