-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrsbuild.config.ts
More file actions
74 lines (71 loc) · 2.2 KB
/
rsbuild.config.ts
File metadata and controls
74 lines (71 loc) · 2.2 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
import { defineConfig, rspack } from '@rsbuild/core';
import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill';
import { version } from './package.json';
const nodeOnlyModules = /^proxy-agent$/;
const unusedInBrowserBuiltins = ['os', 'zlib', 'util'];
const builtinAliases = Object.fromEntries(
unusedInBrowserBuiltins.flatMap((m) => [
[m, false],
[`node:${m}`, false],
]),
);
// eslint-disable-next-line import/no-default-export
export default defineConfig({
source: {
entry: {
Apify: './src/index.ts',
},
define: {
VERSION: JSON.stringify(version),
BROWSER_BUILD: true,
},
},
output: {
distPath: { js: '.' },
filename: { js: 'bundle.js' },
// filename: { js: '[name].js' },
target: 'web',
cleanDistPath: false,
sourceMap: true,
minify: {
jsOptions: {
minimizerOptions: {
mangle: false,
},
},
},
},
tools: {
htmlPlugin: false,
rspack(config) {
config.output = {
...config.output,
library: {
type: 'umd', // or 'umd', 'commonjs', etc.
name: 'Apify',
},
globalObject: 'globalThis',
asyncChunks: false,
};
config.optimization = {
...config.optimization,
providedExports: false,
usedExports: false,
splitChunks: false,
minimize: false,
};
config.plugins = [...(config.plugins ?? []), new rspack.IgnorePlugin({ resourceRegExp: nodeOnlyModules })];
config.resolve = {
...config.resolve,
alias: {
...config.resolve?.alias,
...builtinAliases,
},
};
config.devtool = 'source-map';
},
},
mode: 'production',
// @apify/utilities dynamically imports `crypto` on missing `SubtleCrypto` (but browsers have it).
plugins: [pluginNodePolyfill({ overrides: { crypto: false } })],
});