-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrspack.config.ts
More file actions
113 lines (109 loc) · 2.74 KB
/
rspack.config.ts
File metadata and controls
113 lines (109 loc) · 2.74 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
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
110
111
112
113
'use strict';
import type { Configuration } from '@rspack/core';
import rspack from '@rspack/core';
import path from 'path';
import fs from 'fs/promises';
const extensionConfig: Configuration = {
target: 'node',
entry: './src/extension.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
},
externals: {
vscode: 'commonjs vscode',
'@roamhq/wrtc': 'commonjs @roamhq/wrtc',
// modules added here also need to be added in the .vscodeignore file
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
},
},
},
type: 'javascript/auto',
},
],
},
devtool: 'nosources-source-map',
infrastructureLogging: {
level: 'log', // enables logging required for problem matchers
},
};
const newConfig: Configuration = {
entry: './webview-ui/src/index.tsx',
output: {
// Should be in sync with the scriptUri in webviewManager.ts
filename: 'main.js',
path: path.resolve(__dirname, 'dist', 'webview-ui'),
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/,
resourceQuery: /raw/,
type: 'asset/source',
},
{
test: /\.worker\.ts$/,
include: path.resolve(__dirname, 'src/web-worker'),
use: 'worker-rspack-loader',
},
{
test: /\.(ts)x?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
configFile: false,
presets: ['@babel/preset-env', 'solid', '@babel/preset-typescript'],
plugins: ['solid-refresh/babel'],
},
},
},
{
test: /\.css$/,
use: [
rspack.CssExtractRspackPlugin.loader,
'css-loader',
'postcss-loader',
],
type: 'javascript/auto',
},
],
},
experiments: {
css: false,
},
plugins: [
new rspack.CopyRspackPlugin({
patterns: [
{ from: 'webview-ui/index.html', to: 'index.html' }, // Should be in sync with the htmlPath in webviewManager.ts
],
}),
new rspack.CssExtractRspackPlugin({
filename: 'css/main.css', // Should be in sync with the stylesUri in webviewManager.ts
}),
],
};
export default async () => {
// Clean the output directory before each run to avoid using previous builds
await fs.rm('dist', { recursive: true, force: true });
return [extensionConfig, newConfig];
};