-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrspack.config.js
More file actions
58 lines (52 loc) · 1.69 KB
/
rspack.config.js
File metadata and controls
58 lines (52 loc) · 1.69 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
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const mainTsFiles = glob.sync('./src/**/main.ts').map((filePath) => path.posix.normalize(filePath));
const entry = mainTsFiles.reduce((acc, filePath) => {
const entryName = path.basename(path.dirname(filePath));
acc[entryName] = `./${filePath}`;
return acc;
}, {});
const config = {
mode: process.env.NODE_ENV === 'development' ? 'development' : 'production',
entry,
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
resolve: {
extensions: ['.ts', '.js'],
tsConfig: {
configFile: path.resolve(__dirname, 'tsconfig.json'),
},
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'builtin:swc-loader',
options: {
sourceMap: true,
jsc: {
parser: {
syntax: 'typescript',
},
},
},
type: 'javascript/auto',
},
],
},
optimization: {
// Remain unminized in case any users send errors.
// This keeps line numbers and variable names usable.
// In the future, when rspack implements beautify: true in SwcJsMinimizerRspackPlugin,
// this can be changed.
minimize: false,
// This may be needed if issues arise with module not merging correctly
// concatenateModules: false
},
};
export default config;