generated from web-infra-dev/rspack-repro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rspack.config.mjs
73 lines (70 loc) · 1.81 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
70
71
72
73
import path from "path";
import { fileURLToPath } from "url";
import HtmlWebpackPlugin from "html-webpack-plugin";
const loadableComponents = path.resolve('node_modules', '@swc/plugin-loadable-components', 'swc_plugin_loadable_components.wasm');
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const isRunningWebpack = !!process.env.WEBPACK;
const isRunningRspack = !!process.env.RSPACK;
if (!isRunningRspack && !isRunningWebpack) {
throw new Error("Unknown bundler");
}
/**
* @type {import('webpack').Configuration | import('@rspack/cli').Configuration}
*/
const config = {
mode: "production",
devtool: false,
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: isRunningWebpack? "swc-loader" : "builtin:swc-loader",
options: {
minify: false,
jsc: {
experimental: {
plugins: [
[loadableComponents, {}],
],
},
},
env: {
targets: [
'Chrome >= 105',
'Firefox >= 105',
'Edge >= 105',
'Android >= 105',
'Samsung >= 21',
'iOS_Saf >= 15',
'Safari >= 15',
],
bugfixes: true,
exclude: ['proposal-object-rest-spread'],
},
},
}
}
]
},
entry: {
main: "./src/index",
},
plugins: [new HtmlWebpackPlugin()],
optimization: {
minimize: false,
},
output: {
clean: true,
path: isRunningWebpack
? path.resolve(__dirname, "webpack-dist")
: path.resolve(__dirname, "rspack-dist"),
filename: "[name].js",
},
experiments: {
css: true,
},
target: 'web'
};
export default config;