-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrspack.config.mjs
More file actions
56 lines (55 loc) · 1.34 KB
/
rspack.config.mjs
File metadata and controls
56 lines (55 loc) · 1.34 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 path from 'path';
export default defineConfig({
entry: {
server: './src/server.jsx',
client: './src/client.jsx'
},
output: {
// 整体的输出目录
path: path.resolve(process.cwd(), 'dist'),
// 使用函数根据入口名称动态生成输出文件名和路径
filename: (pathData) => {
if (pathData.chunk.name === 'client') {
return path.relative(
path.resolve(process.cwd(), 'dist'),
path.resolve(process.cwd(), 'public', '[name].js')
);
}
// 其他入口按默认规则输出
return '[name].js';
}
},
target: "node",
optimization: {
minimize: false
},
module: {
rules: [
{
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',
},
],
},
});