-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrspack.config.js
More file actions
94 lines (93 loc) · 2.34 KB
/
rspack.config.js
File metadata and controls
94 lines (93 loc) · 2.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
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
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const {
HtmlRspackPlugin,
container: { ModuleFederationPlugin },
} = require("@rspack/core");
const path = require("path");
const rspack = require("@rspack/core");
module.exports = {
entry: "./src/index.tsx",
mode: "development",
target: "web",
devServer: {
static: {
directory: path.join(__dirname, "dist"),
},
port: 3001,
},
output: {
publicPath: "auto",
},
module: {
rules: [
{
test: /\.(js|ts)x?$/,
include: path.resolve(__dirname, "src"),
use: {
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "typescript",
jsx: true,
},
transform: {
react: {
runtime: "automatic",
},
},
},
},
},
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ["@svgr/webpack"],
},
],
},
plugins: [
new ModuleFederationPlugin({
name: "webdeck",
// adds react as shared module
// version is inferred from package.json
// there is no version check for the required version
// so it will always use the higher version found
shared: {
react: {
import: "react", // the "react" package will be used a provided and fallback module
shareKey: "react", // under this name the shared module will be placed in the share scope
shareScope: "default", // share scope with this name will be used
singleton: true, // only a single version of the shared module is allowed
},
"react-dom": {
singleton: true, // only a single version of the shared module is allowed
},
},
}),
new rspack.CopyRspackPlugin({
patterns: [
{
from: "public",
globOptions: {
ignore: ["**/template.html"],
},
},
],
}),
new HtmlRspackPlugin({
template: "./public/template.html",
}),
],
// it will be fixed soon...
resolve: {
extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
alias: {
"@module-federation/runtime$": require.resolve(
"@module-federation/runtime"
),
},
},
};