-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrspack.config.js
109 lines (106 loc) · 2.76 KB
/
rspack.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// @ts-check
const path = require('path');
/**
* Rspack supports multi-compiler by returning an array of configurations,
* similar to webpack. Each config can have different entry, target, and rules.
*
* @type {import('@rspack/cli').Configuration[]}
*/
module.exports = [
// ========== 1) Extension (backend) config ==========
{
name: 'extension',
target: 'node', // The extension runs in Node context
entry: {
extension: './src/extension/extension.ts'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: 'commonjs2'
},
externals: {
vscode: 'commonjs vscode' // must exclude the vscode module
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [
{
test: /\.tsx?$/,
include: path.resolve(__dirname, 'src/extension'),
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.extension.json'
}
}
]
},
// If you have other rules (e.g., for keytar.node) in the extension:
{
test: /\keytar.node$/,
use: { loader: "file-loader" }
}
]
},
// Typically you'd set devtool for your extension bundling:
devtool: 'nosources-source-map'
},
// ========== 2) Webview (frontend) config ==========
{
name: 'webview',
target: 'web', // The webview runs in a browser environment
entry: {
webview: './src/webview/index.tsx'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'webview.js',
// If you want to use ESM in the webview (e.g., to do <script type="module">),
// you can specify `library: { type: 'module' }` and `experiments.outputModule = true`.
library: {
type: 'module'
}
},
experiments: {
// needed if you use 'type: module' in the library output
outputModule: true
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [
{
test: /\.tsx?$/,
include: path.resolve(__dirname, 'src/webview'),
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.webview.json'
}
}
]
},
// If you have CSS/Tailwind, also add style-loader, css-loader, etc.
// e.g.:
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader']
}
]
},
// For easier debugging in the webview
devtool: 'source-map',
performance: {
hints: false
},
optimization: {
minimize: false
}
}
];