-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrspack.config.ts
More file actions
93 lines (89 loc) · 2.02 KB
/
rspack.config.ts
File metadata and controls
93 lines (89 loc) · 2.02 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
/* eslint-env node */
import path from "node:path";
import HtmlWebpackPlugin from "html-webpack-plugin";
import StatoscopeWebpackPlugin from "@statoscope/webpack-plugin";
import reports from "./reports";
import WebpackContextExtension from "./custom-ext";
import rspack from "@rspack/core";
import {RsdoctorRspackPlugin} from "@rsdoctor/rspack-plugin";
const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development';
module.exports = {
mode,
entry: {
main: './src/index.js',
},
output: {
path: path.resolve('public'),
filename: '[name].[contenthash:7].js',
},
devServer: {
port: 8888,
devMiddleware: {
writeToDisk: true,
},
},
resolve: {
symlinks: false,
},
module: {
noParse: [/@statoscope/],
rules: [
{
test: /\.svg$/,
type: 'asset/resource',
},
{
test: /\.js?$/,
exclude: /node_modules/,
use: 'babel-loader',
},
{
test: /\.css$/,
include: [path.resolve('src')],
use: [
rspack.CssExtractRspackPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
type: 'javascript/auto',
},
{
test: /\.html$/i,
use: {
loader: 'html-loader',
options: {
interpolate: true,
},
},
},
],
},
plugins: [
process.env.RSDOCTOR &&
new RsdoctorRspackPlugin({
// plugin options
}),
new StatoscopeWebpackPlugin({
statsOptions: {
context: __dirname,
},
saveStatsTo: path.resolve('./public/demo-stats.rspack.json'),
normalizeStats: true,
open: 'file',
reports,
extensions: [new WebpackContextExtension()],
}),
new rspack.CssExtractRspackPlugin({
filename: '[name].[contenthash:7].css',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
minify: false,
}),
],
};