-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrspack.config.ts
More file actions
56 lines (54 loc) · 1.31 KB
/
rspack.config.ts
File metadata and controls
56 lines (54 loc) · 1.31 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
import { defineConfig } from '@rspack/cli';
import { type SwcLoaderOptions, rspack } from '@rspack/core';
import { ReactRefreshRspackPlugin } from '@rspack/plugin-react-refresh';
const isDev = process.env.NODE_ENV === 'development';
export default defineConfig({
entry: {
main: './src/main.tsx',
},
target: ['browserslist:last 2 versions, > 0.2%, not dead, Firefox ESR'],
resolve: {
extensions: ['...', '.ts', '.tsx', '.jsx'],
},
module: {
rules: [
{
test: /\.svg$/,
type: 'asset',
},
{
test: /\.css$/,
type: 'css/auto',
},
{
test: /\.(jsx?|tsx?)$/,
use: [
{
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
development: isDev,
refresh: isDev,
},
},
},
} satisfies SwcLoaderOptions,
},
],
},
],
},
plugins: [
new rspack.HtmlRspackPlugin({
template: './index.html',
}),
isDev ? new ReactRefreshRspackPlugin() : null,
],
});