-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrspack.config.js
157 lines (156 loc) · 3.33 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
const {
ModuleFederationPlugin,
} = require("@module-federation/enhanced/rspack");
const rspack = require("@rspack/core");
module.exports = {
module: {
rules: [
{
test: /\.png$/,
use: [
{
loader: ImageMinimizerPlugin.loader,
options: {
// ...
},
},
],
type: "asset/resource",
},
{
test: /\.css$/,
use: [
{
loader: "builtin:lightningcss-loader",
options: {
targets: ["ie 10", "chrome >= 87", "edge >= 88", "> 0.5%"],
},
},
// ... other loader
],
},
{
test: /\.ts$/,
exclude: [/node_modules/],
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "typescript",
},
},
},
type: "javascript/auto",
},
{
test: /\.jsx$/,
use: {
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "ecmascript",
jsx: true,
},
transform: {
react: {
pragma: "React.createElement",
pragmaFrag: "React.Fragment",
throwIfNamespace: true,
development: false,
useBuiltins: false,
},
},
},
},
},
type: "javascript/auto",
},
{
test: /\.js$/,
use: {
loader: "builtin:swc-loader",
options: {
jsc: {
target: "es2015",
},
env: {
targets: [
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
// ...other options
},
},
},
{
test: /\.less$/,
use: [
{
loader: "postcss-loader",
},
{
loader: "less-loader",
},
],
type: "css",
},
{
test: /\.css$/,
use: [
{
loader: "postcss-loader",
options: {
postcssOptions: {
// ...
},
},
},
],
type: "css",
},
],
},
devServer: {
hot: false,
proxy: [
{
context: ["/api"],
target: "http://localhost:3000",
changeOrigin: true,
},
],
},
// 模块联邦
plugins: [
new ModuleFederationPlugin({
// options
}),
// HtmlRspackPlugin 是以 Rust 实现的高性能 HTML 插件
new rspack.HtmlRspackPlugin(),
],
experiments: {
css: true,
},
entry: "index.js",
output: {
// set uniqueName explicitly to make HMR works
uniqueName: "app",
path: path.resolve(__dirname, "./dist"),
filename: "index_bundle.js",
},
optimization: {
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin({
// JS minimizer 配置
}),
new rspack.LightningCssMinimizerRspackPlugin({
// CSS minimizer 配置
}),
],
},
};