-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathwebpack.config.cjs
More file actions
60 lines (50 loc) · 1.53 KB
/
webpack.config.cjs
File metadata and controls
60 lines (50 loc) · 1.53 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
const { makeConfig } = require('@anansi/webpack-config');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const LIBRARIES = ['data-client', 'tanstack-query', 'swr', 'baseline'];
const entries = {};
for (const lib of LIBRARIES) {
entries[lib] = `./src/${lib}/index.tsx`;
}
const options = {
rootPath: __dirname,
basePath: 'src',
buildDir: 'dist/',
globalStyleDir: 'style',
sassOptions: false,
nohash: true,
};
const generateConfig = makeConfig(options);
module.exports = (env, argv) => {
const config = generateConfig(env, argv);
config.resolve = config.resolve || {};
config.resolve.alias = {
...config.resolve.alias,
'@shared': path.resolve(__dirname, 'src/shared'),
swr: require.resolve('swr'),
};
// Remove worker-loader rule — we use webpack 5's native Worker support
if (config.module?.rules?.[0]?.oneOf) {
config.module.rules[0].oneOf = config.module.rules[0].oneOf.filter(
r => !r.test || !String(r.test).includes('worker'),
);
}
config.entry = entries;
config.output.filename = '[name].js';
config.output.chunkFilename = '[name].chunk.js';
config.plugins = config.plugins.filter(
p => p.constructor.name !== 'HtmlWebpackPlugin',
);
for (const lib of LIBRARIES) {
config.plugins.push(
new HtmlWebpackPlugin({
title: `Benchmark: ${lib}`,
filename: path.join(lib, 'index.html'),
chunks: [lib],
scriptLoading: 'defer',
}),
);
}
return config;
};
module.exports.options = options;