-
Notifications
You must be signed in to change notification settings - Fork 1
/
rspack.config.mjs
69 lines (67 loc) · 1.76 KB
/
rspack.config.mjs
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
// @ts-check
import { defineConfig } from "@rspack/cli";
import { rspack } from "@rspack/core";
import ReactRefreshPlugin from "@rspack/plugin-react-refresh";
const isProduction = process.env.NODE_ENV === "production";
export default defineConfig({
entry: {
main: "./src/index.tsx",
},
resolve: {
extensions: ["...", ".tsx", ".ts", ".jsx"],
},
module: {
rules: [
{
test: /\.svg$/,
type: "asset",
},
{
test: /\.(js|ts|tsx|jsx)$/,
exclude: /node_modules/,
use: {
loader: "builtin:swc-loader",
/** @type {import('@rspack/core').SwcLoaderOptions} */
options: {
env: {
targets: [
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
jsc: {
parser: {
syntax: "typescript",
tsx: true,
},
transform: {
react: {
runtime: "automatic",
development: !isProduction,
refresh: !isProduction,
},
},
},
},
},
},
],
},
watchOptions: {
// TODO: will be default in Rspack v1.2.0
ignored: /[\\/](?:\.git|node_modules)[\\/]/,
},
plugins: [
new rspack.HtmlRspackPlugin({ template: "./index.rspack.html" }),
!isProduction && new ReactRefreshPlugin(),
].filter(Boolean),
experiments: {
css: true,
// lazyCompilation should only be enabled in development mode
lazyCompilation: Boolean(process.env.LAZY) && !isProduction,
incremental:
Boolean(process.env.INCREMENTAL) && !isProduction ? true : undefined,
},
});