-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrspack.config.js
More file actions
69 lines (68 loc) · 1.83 KB
/
Copy pathrspack.config.js
File metadata and controls
69 lines (68 loc) · 1.83 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
import { rspack } from '@rspack/core'
export default {
cache: {
type: 'persistent'
},
context: import.meta.dirname,
entry: './src/index.jsx',
output: {
path: `${import.meta.dirname}/dist`,
clean: true
},
module: {
rules: [
{
// The app code is JSX, and the workspace packages resolve to their
// TypeScript sources in this repo - one rule covers both, swc infers
// the syntax from the extension. An installed package ships compiled
// JS and needs none of this.
test: /\.[jt]sx?$/,
loader: 'builtin:swc-loader',
options: {
detectSyntax: 'auto',
jsc: {
transform: {
react: {
// No `import React` needed in the components.
runtime: 'automatic'
}
}
}
}
},
{
test: /\.(jpe?g|png|gif)$/i,
use: {
loader: '@srcset/loader',
options: {
rules: [
// Png: keep png as the fallback so transparency survives, add webp.
{
match: '**/*.png',
width: [1, 0.5],
format: ['png', 'webp']
},
// Gif: keep gif as the fallback, add animated webp.
{
match: '**/*.gif',
width: [1, 0.5],
format: ['gif', 'webp']
},
// Everything else - photos. The import query of the first demo overrides this rule.
{
width: [1, 0.5],
format: ['jpg', 'webp', 'avif']
}
]
}
}
}
]
},
plugins: [
// Rspack's built-in html plugin - no html-webpack-plugin needed.
new rspack.HtmlRspackPlugin({
template: './index.html'
})
]
}