-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrspack.config.js
88 lines (86 loc) · 2.19 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
// @ts-check
const path = require('path');
const { defineConfig } = require('@rspack/cli');
const rspack = require('@rspack/core');
module.exports = (env, argv) => defineConfig({
entry: {
popup: './src/popup/popup.tsx',
sidePanel: './src/sidePanel/sidePanel.tsx',
background: './src/scripts/background.ts',
contentScript: './src/scripts/contentScript.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
clean: true,
},
resolve: {
extensions: ['.ts', '.js', 'tsx'],
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
pragma: 'React.createElement',
pragmaFrag: 'React.Fragment',
throwIfNamespace: true,
development: false,
useBuiltins: false,
},
},
},
},
},
type: 'javascript/auto',
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: [rspack.CssExtractRspackPlugin.loader, 'css-loader', 'postcss-loader'],
}
],
},
plugins: [
new rspack.CssExtractRspackPlugin({
filename: '[name].css',
}),
new rspack.HtmlRspackPlugin({
template: './src/popup/popup.html',
filename: 'popup.html',
chunks: ['popup'],
minify: true,
}),
new rspack.HtmlRspackPlugin({
template: './src/sidePanel/sidePanel.html',
filename: 'sidePanel.html',
chunks: ['sidePanel'],
minify: true,
}),
new rspack.CopyRspackPlugin({
patterns: [
{ from: 'public', to: 'public' },
{ from: 'src/manifest.json', to: 'manifest.json' },
{ from: '_locales', to: '_locales' },
],
}),
],
mode: argv.mode,
devtool: argv.mode === 'development' ? 'inline-source-map' : false,
optimization: {
// minimize: argv.mode === 'production',
minimize: true,
},
});