-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrspack.config.js
66 lines (62 loc) · 1.49 KB
/
rspack.config.js
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
const HtmlPlugin = require('@rspack/plugin-html').default;
const path = require('path');
const isProduction = process.env.NODE_ENV === 'production';
const extensions = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.json', '.css'];
/**
* @type {import('@rspack/cli').Configuration}
*/
module.exports = {
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? false : 'inline-source-map',
entry: {
ui: './src/app/index.tsx',
code: './src/plugin/code.ts',
},
stats: {
errors: true,
warnings: true,
},
module: {
rules: [
{
test: /\.css$/,
use: ['postcss-loader'],
type: 'css',
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
type: 'asset/resource',
},
],
},
resolve: {
extensions,
tsConfigPath: path.resolve(__dirname, 'tsconfig.json'),
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new HtmlPlugin({
template: './src/app/index.ejs',
filename: 'ui.html',
chunks: ['ui'],
cache: false,
inject: false,
minify: {
collapseWhitespace: true,
removeComments: true,
},
templateParameters: (compilation) => {
const res = {
inlineCss: compilation.assets['ui.css'].source(),
inlineJS: compilation.assets['ui.js'].source(),
};
compilation.deleteAsset('ui.css');
compilation.deleteAsset('ui.js');
return res;
},
}),
],
};