forked from farm-fe/performance-compare
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrspack.config.js
84 lines (82 loc) · 1.65 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
const rspack = require('@rspack/core');
const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
const path = require('path');
const generateSwcOptions = (syntax, isProd) => ({
jsc: {
parser: {
syntax,
jsx: true,
dynamicImport: true,
privateMethod: true,
functionBind: true,
classPrivateProperty: true,
exportDefaultFrom: true,
exportNamespaceFrom: true,
decorators: true,
decoratorsBeforeExport: true,
importMeta: true,
},
transform: {
react: {
runtime: "automatic",
development: !isProd,
refresh: !isProd,
},
},
},
})
module.exports = function (env, argv) {
const isBuild = argv['_'][0] === 'build'
/**
* @type {import('@rspack/cli').Configuration}
*/
return {
context: __dirname,
entry: {
main: "./src/index.tsx"
},
output: {
path: path.resolve(__dirname, './dist-rspack')
},
target: 'browserslist',
resolve: {
extensions: ['.tsx', '.jsx', '.ts', '.js', '.json']
},
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'builtin:swc-loader',
options: generateSwcOptions('typescript', isBuild),
},
exclude: /node_modules/
},
{
test: /\.jsx?$/,
use: {
loader: 'builtin:swc-loader',
options: generateSwcOptions('ecmascript', isBuild),
}
},
{
test: /\.svg$/,
type: "asset"
}
]
},
plugins: [
new rspack.HtmlRspackPlugin({ template: './index.webpack.html' }),
!isBuild && new ReactRefreshPlugin()
],
watchOptions: {
poll: 0,
aggregateTimeout: 0
},
devtool: isBuild ? false : 'nosources-cheap-source-map',
stats: {
timings: true,
all: false
}
};
};