forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrspack.config.mjs
More file actions
51 lines (47 loc) · 1.4 KB
/
rspack.config.mjs
File metadata and controls
51 lines (47 loc) · 1.4 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
// @ts-check
/** @typedef {import('@rushstack/heft-rspack-plugin').IRspackConfiguration} IRspackConfiguration */
'use strict';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { HtmlRspackPlugin, SwcJsMinimizerRspackPlugin } from '@rspack/core';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
/** @type {IRspackConfiguration} */
const config = {
mode: 'production',
module: {
rules: [
{
test: /\.png$/i,
type: 'asset/resource'
},
{
test: /\.js$/,
enforce: 'pre'
// TODO: enable after rspack drops a new version with this commit https://github.com/web-infra-dev/rspack/commit/d31f2fa07179d72eee99b21db517946d08073767
// extractSourceMap: true
}
]
},
target: ['web', 'es2020'],
resolve: {
extensions: ['.js', '.json']
},
entry: {
'heft-test-A': resolve(__dirname, 'lib-esm', 'indexA.js'),
'heft-test-B': resolve(__dirname, 'lib-esm', 'indexB.js')
},
output: {
path: resolve(__dirname, 'dist'),
filename: '[name]_[contenthash].js',
chunkFilename: '[id].[name]_[contenthash].js',
assetModuleFilename: '[name]_[contenthash][ext][query]'
},
devtool: 'source-map',
optimization: {
minimize: true,
minimizer: [new SwcJsMinimizerRspackPlugin({})]
},
plugins: [new HtmlRspackPlugin()]
};
export default config;