-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathrspack.config.js
More file actions
148 lines (146 loc) · 3.13 KB
/
rspack.config.js
File metadata and controls
148 lines (146 loc) · 3.13 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const path = require('path');
const {rspack} = require('@rspack/core');
const services = require('./site/services.json');
const package = require('./package.json');
const {standaloneEntries} = require('./build/entries');
const {
templatePlugin,
featureTemplatePlugin,
assetsPlugin,
matomoPlugin
} = require('./build/site');
const fullPath = path.resolve.bind(path, __dirname);
const isDev = process.env.NODE_ENV === 'development';
module.exports = {
mode: isDev ? 'development' : 'production',
devtool: isDev ? 'eval-source-map' : false,
devServer: {
port: 3000,
compress: true,
static: {
directory: fullPath('dist')
},
client: {
overlay: false
}
},
entry: {
migrations: './src/migrations/index.ts',
...standaloneEntries()
},
output: {
filename: '[name].js',
path: fullPath('dist'),
clean: true
},
module: {
rules: [
{
test: /\.tsx?$/,
include: fullPath('src'),
type: 'javascript/auto',
use: {
loader: 'builtin:swc-loader',
options: {
env: {
// @see https://github.com/swc-project/swc-loader/issues/37#issuecomment-1233829398
targets: package.browserslist
},
jsc: {
externalHelpers: true,
preserveAllComments: false,
parser: {
syntax: 'typescript',
tsx: true
},
transform: {
react: {
runtime: 'automatic',
importSource: 'preact'
}
}
}
}
}
},
{
test: /\.css$/i,
type: 'javascript/auto',
use: [
rspack.CssExtractRspackPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['postcss-preset-env']
}
}
}
]
}
]
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
alias: {
// Avoids a warning from uneval.
'internal-prop': false
},
fallback: {
fs: false
}
},
optimization: {
// Prevents rspack from splitting anything more than
// the explicit chunks created from dynamic imports.
splitChunks: false
},
plugins: [
new rspack.CssExtractRspackPlugin({
filename: 'orejime-standard.css'
}),
templatePlugin({
title: 'A lightweight and accessible consent manager',
chunks: ['migrations'],
params: {
services
}
}),
templatePlugin({
title: 'Legal information & privacy policy',
template: 'legal'
}),
templatePlugin({
title: 'Accessibility statement',
template: 'accessibility'
}),
featureTemplatePlugin({title: 'Purposes', feature: 'purposes'}),
featureTemplatePlugin({title: 'Grouping', feature: 'grouping'}),
featureTemplatePlugin({
title: 'Internationalization',
feature: 'i18n',
lang: 'fr'
}),
featureTemplatePlugin({title: 'Styling', feature: 'styling'}),
featureTemplatePlugin({
title: 'Contextual consent',
feature: 'contextual',
template: 'contextual'
}),
featureTemplatePlugin({
title: "Intégration au système de design de l'état",
feature: 'dsfr',
template: 'dsfr',
chunks: [],
lang: 'fr'
}),
featureTemplatePlugin({
title: 'WCAG compliance',
feature: 'wcag',
template: 'wcag'
}),
assetsPlugin(),
matomoPlugin()
]
};