-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrspack.render.config.ts
95 lines (92 loc) · 2.14 KB
/
rspack.render.config.ts
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
import { Configuration } from '@rspack/cli';
import { rspack } from '@rspack/core';
import RefreshPlugin from '@rspack/plugin-react-refresh';
import path from 'path';
const isDev = process.env.NODE_ENV === 'development';
const config: Configuration = {
mode: isDev ? 'development' : 'production',
entry: {
index: path.resolve(__dirname, './src/renderer/index.tsx'),
},
output: {
path: path.resolve(__dirname, 'build'),
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
},
resolve: {
extensions: ['...', '.ts', '.tsx', '.jsx'],
alias: {
'@': path.resolve(__dirname, 'src', 'renderer'),
},
},
devServer: {
port: 3000,
open: false,
historyApiFallback: false,
},
module: {
parser: {
'css/auto': {
namedExports: false,
},
},
rules: [
{
test: /\.(jsx?|tsx?)$/,
use: [
{
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
},
},
],
},
{
test: /\.less$/,
loader: require.resolve('less-loader'),
options: {
lessOptions: {
javascriptEnabled: true,
},
},
type: 'css/auto',
},
{
test: /\.(png|svg|webp|jpe?g|gif)(\?.*)?$/i,
type: 'asset',
generator: {
filename: 'assets/[hash][ext]',
},
},
],
},
plugins: [
new rspack.HtmlRspackPlugin({
template: path.resolve(__dirname, './src/renderer/index.html'),
}),
new rspack.ProgressPlugin({}),
new rspack.CopyRspackPlugin({
patterns: [
{
from: path.resolve(__dirname, './src/renderer/public'),
to: path.resolve(__dirname, './build'),
},
],
}),
isDev ? new RefreshPlugin() : null,
].filter(Boolean),
experiments: {
css: true,
},
};
export = config;