@workleap/rsbuild-configs 3.2.7 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/build.d.ts +5 -3
- package/dist/build.js +37 -31
- package/dist/build.js.map +1 -1
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +5 -7
- package/dist/dev.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/storybook.js +1 -1
- package/dist/storybook.js.map +1 -1
- package/package.json +19 -18
- package/src/build.ts +47 -30
- package/src/dev.ts +6 -6
- package/src/storybook.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @workleap/rsbuild-configs
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#430](https://github.com/workleap/wl-web-configs/pull/430) [`0243027`](https://github.com/workleap/wl-web-configs/commit/02430272d8e9eb714b9c0b3a7e68fec91c750c6b) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Add new options aligned with [Rsbuild 2.0](https://rsbuild.rs/blog/v2-0):
|
|
8
|
+
- New `polyfill` option on `defineBuildConfig`. Defaults to `"usage"`. `core-js` is now declared as a direct dependency of `@workleap/rsbuild-configs` to preserve out-of-the-box polyfill support after Rsbuild 2.0 stopped installing it by default.
|
|
9
|
+
- New `splitChunks` option on `defineBuildConfig`. Defaults to `{ preset: "per-package", chunks: "all" }`, replacing the deprecated `performance.chunkSplit`. Each npm package is now emitted in its own chunk for better long-term caching.
|
|
10
|
+
- New `setup` option on `defineDevConfig`, exposing Rsbuild's `server.setup` hook.
|
|
11
|
+
|
|
12
|
+
Internal refactor of `getOptimizationConfig` to use Rsbuild's `output.minify` shape. The user-facing `optimize` and `minify` options behave identically.
|
|
13
|
+
|
|
14
|
+
A new [Migrate to v2.0](https://workleap.github.io/wl-web-configs/rsbuild/migrate-to-v2/) page is available in the documentation.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#430](https://github.com/workleap/wl-web-configs/pull/430) [`0243027`](https://github.com/workleap/wl-web-configs/commit/02430272d8e9eb714b9c0b3a7e68fec91c750c6b) Thanks [@patricklafrance](https://github.com/patricklafrance)! - (Should have been 4.0.0 my bad) - Update the package configurations and API to match the new Rsbuild 2.0 features / improvements / deprecation.
|
|
19
|
+
|
|
20
|
+
## 4.0.0
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- [#425](https://github.com/workleap/wl-web-configs/pull/425) [`8de3e5a`](https://github.com/workleap/wl-web-configs/commit/8de3e5a26effe1f00cb905b4be5a24a961f50c5b) Thanks [@claude](https://github.com/apps/claude)! - Updated dependencies to their latest versions. Migrated `@workleap/rsbuild-configs` to `@rsbuild/core` 2.x, `@rspack/core` 2.x, and `@rsbuild/plugin-react` 2.x — `removeAvailableModules` was removed from the rspack `Optimization` type and `reactRefreshOptions.overlay` was removed from the react plugin (overlay is now controlled solely via `dev.client.overlay`).
|
|
25
|
+
|
|
3
26
|
## 3.2.7
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/build.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type DistPathConfig, type HtmlConfig, type Minify, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type SourceMap } from "@rsbuild/core";
|
|
1
|
+
import { type DistPathConfig, type HtmlConfig, type Minify, type Polyfill, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type SourceMap, type SplitChunksConfig } from "@rsbuild/core";
|
|
2
2
|
import { type PluginImageCompressOptions } from "@rsbuild/plugin-image-compress";
|
|
3
3
|
import { type PluginReactOptions } from "@rsbuild/plugin-react";
|
|
4
4
|
import { type PluginSvgrOptions } from "@rsbuild/plugin-svgr";
|
|
5
|
-
import {
|
|
5
|
+
import type { Optimization } from "@rspack/core";
|
|
6
6
|
import { type RsbuildConfigTransformer } from "./applyTransformers.ts";
|
|
7
7
|
export type OptimizeOption = boolean | "readable";
|
|
8
8
|
export type DefineBuildHtmlPluginConfigFunction = (defaultOptions: HtmlConfig) => HtmlConfig;
|
|
@@ -18,6 +18,8 @@ export interface DefineBuildConfigOptions {
|
|
|
18
18
|
minify?: Minify;
|
|
19
19
|
optimize?: OptimizeOption;
|
|
20
20
|
sourceMap?: boolean | SourceMap;
|
|
21
|
+
polyfill?: Polyfill;
|
|
22
|
+
splitChunks?: SplitChunksConfig | false;
|
|
21
23
|
react?: false | DefineBuildDefineReactPluginConfigFunction;
|
|
22
24
|
svgr?: false | DefineBuildSvgrPluginConfigFunction;
|
|
23
25
|
compressImage?: false | DefineBuildImageCompressPluginConfigFunction;
|
|
@@ -25,5 +27,5 @@ export interface DefineBuildConfigOptions {
|
|
|
25
27
|
transformers?: RsbuildConfigTransformer[];
|
|
26
28
|
verbose?: boolean;
|
|
27
29
|
}
|
|
28
|
-
export declare function getOptimizationConfig(optimize: OptimizeOption): Optimization;
|
|
30
|
+
export declare function getOptimizationConfig(optimize: OptimizeOption): Optimization | undefined;
|
|
29
31
|
export declare function defineBuildConfig(options?: DefineBuildConfigOptions): RsbuildConfig;
|
package/dist/build.js
CHANGED
|
@@ -2,7 +2,6 @@ import { defineConfig } from "@rsbuild/core";
|
|
|
2
2
|
import { pluginImageCompress } from "@rsbuild/plugin-image-compress";
|
|
3
3
|
import { pluginReact } from "@rsbuild/plugin-react";
|
|
4
4
|
import { pluginSvgr } from "@rsbuild/plugin-svgr";
|
|
5
|
-
import { SwcJsMinimizerRspackPlugin } from "@rspack/core";
|
|
6
5
|
import node_path from "node:path";
|
|
7
6
|
import { applyTransformers } from "./applyTransformers.js";
|
|
8
7
|
|
|
@@ -18,8 +17,6 @@ import { applyTransformers } from "./applyTransformers.js";
|
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
20
|
function defaultDefineHtmlPluginConfig(options) {
|
|
24
21
|
return options;
|
|
25
22
|
}
|
|
@@ -32,40 +29,44 @@ function defineSvgrPluginConfig(options) {
|
|
|
32
29
|
function defineImageCompressPluginConfig(options) {
|
|
33
30
|
return options;
|
|
34
31
|
}
|
|
35
|
-
function
|
|
36
|
-
if (optimize ===
|
|
32
|
+
function getMinifyConfig(optimize, minify) {
|
|
33
|
+
if (optimize === false) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (optimize === "readable") {
|
|
37
37
|
return {
|
|
38
|
-
|
|
38
|
+
jsOptions: {
|
|
39
|
+
minimizerOptions: {
|
|
40
|
+
mangle: false,
|
|
41
|
+
compress: {
|
|
42
|
+
toplevel: true,
|
|
43
|
+
hoist_props: false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
39
47
|
};
|
|
40
|
-
}
|
|
48
|
+
}
|
|
49
|
+
return minify;
|
|
50
|
+
}
|
|
51
|
+
function getOptimizationConfig(optimize) {
|
|
52
|
+
if (optimize === "readable") {
|
|
41
53
|
return {
|
|
42
|
-
minimize: true,
|
|
43
|
-
minimizer: [
|
|
44
|
-
new SwcJsMinimizerRspackPlugin({
|
|
45
|
-
minimizerOptions: {
|
|
46
|
-
mangle: false,
|
|
47
|
-
compress: {
|
|
48
|
-
toplevel: true,
|
|
49
|
-
hoist_props: false
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
],
|
|
54
54
|
chunkIds: "named",
|
|
55
55
|
moduleIds: "named",
|
|
56
56
|
mangleExports: false
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
59
|
+
if (optimize === false) {
|
|
60
|
+
// Doesn't turn off everything but is good enough to help with debugging scenarios.
|
|
61
|
+
return {
|
|
62
|
+
chunkIds: "named",
|
|
63
|
+
moduleIds: "named",
|
|
64
|
+
concatenateModules: false,
|
|
65
|
+
mangleExports: false,
|
|
66
|
+
usedExports: false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
69
70
|
}
|
|
70
71
|
function defineBuildConfig(options = {}) {
|
|
71
72
|
const { entry = {
|
|
@@ -75,6 +76,9 @@ function defineBuildConfig(options = {}) {
|
|
|
75
76
|
}, assetPrefix = "/", plugins = [], html = defaultDefineHtmlPluginConfig, minify = true, optimize = true, sourceMap = {
|
|
76
77
|
js: "source-map",
|
|
77
78
|
css: true
|
|
79
|
+
}, polyfill = "usage", splitChunks = {
|
|
80
|
+
preset: "per-package",
|
|
81
|
+
chunks: "all"
|
|
78
82
|
}, react = defaultDefineReactPluginConfig, svgr = defineSvgrPluginConfig, compressImage = defineImageCompressPluginConfig, // Using an empty object literal as the default value to ensure
|
|
79
83
|
// "process.env" is always available.
|
|
80
84
|
environmentVariables = {}, transformers = [], verbose = false } = options;
|
|
@@ -97,9 +101,11 @@ function defineBuildConfig(options = {}) {
|
|
|
97
101
|
distPath,
|
|
98
102
|
cleanDistPath: true,
|
|
99
103
|
assetPrefix,
|
|
100
|
-
minify,
|
|
101
|
-
sourceMap
|
|
104
|
+
minify: getMinifyConfig(optimize, minify),
|
|
105
|
+
sourceMap,
|
|
106
|
+
polyfill
|
|
102
107
|
},
|
|
108
|
+
splitChunks,
|
|
103
109
|
html: html ? html({
|
|
104
110
|
template: node_path.resolve("./public/index.html")
|
|
105
111
|
}) : undefined,
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["../src/build.ts"],"sourcesContent":["import { defineConfig, type DistPathConfig, type HtmlConfig, type Minify, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type SourceMap } from \"@rsbuild/core\";\nimport { pluginImageCompress, type PluginImageCompressOptions } from \"@rsbuild/plugin-image-compress\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport {
|
|
1
|
+
{"version":3,"file":"build.js","sources":["../src/build.ts"],"sourcesContent":["import { defineConfig, type DistPathConfig, type HtmlConfig, type Minify, type Polyfill, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type SourceMap, type SplitChunksConfig } from \"@rsbuild/core\";\nimport { pluginImageCompress, type PluginImageCompressOptions } from \"@rsbuild/plugin-image-compress\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport type { Optimization } from \"@rspack/core\";\nimport path from \"node:path\";\nimport { applyTransformers, type RsbuildConfigTransformer } from \"./applyTransformers.ts\";\n\nexport type OptimizeOption = boolean | \"readable\";\n\nexport type DefineBuildHtmlPluginConfigFunction = (defaultOptions: HtmlConfig) => HtmlConfig;\nexport type DefineBuildDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineBuildSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\nexport type DefineBuildImageCompressPluginConfigFunction = (defaultOptions: PluginImageCompressOptions) => PluginImageCompressOptions;\n\nexport interface DefineBuildConfigOptions {\n entry?: RsbuildEntry;\n // Similar to webpack.output.path.\n distPath?: DistPathConfig;\n // Similar to webpack.publicPath.\n assetPrefix?: string;\n plugins?: RsbuildPlugins;\n html?: false | DefineBuildHtmlPluginConfigFunction;\n minify?: Minify;\n optimize?: OptimizeOption;\n sourceMap?: boolean | SourceMap;\n polyfill?: Polyfill;\n splitChunks?: SplitChunksConfig | false;\n react?: false | DefineBuildDefineReactPluginConfigFunction;\n svgr?: false | DefineBuildSvgrPluginConfigFunction;\n compressImage?: false | DefineBuildImageCompressPluginConfigFunction;\n environmentVariables?: Record<string, unknown>;\n transformers?: RsbuildConfigTransformer[];\n verbose?: boolean;\n}\n\nfunction defaultDefineHtmlPluginConfig(options: HtmlConfig) {\n return options;\n}\n\nfunction defaultDefineReactPluginConfig(options: PluginReactOptions) {\n return options;\n}\n\nfunction defineSvgrPluginConfig(options: PluginSvgrOptions) {\n return options;\n}\n\nfunction defineImageCompressPluginConfig(options: PluginImageCompressOptions) {\n return options;\n}\n\nfunction getMinifyConfig(optimize: OptimizeOption, minify: Minify): Minify {\n if (optimize === false) {\n return false;\n }\n\n if (optimize === \"readable\") {\n return {\n jsOptions: {\n minimizerOptions: {\n mangle: false,\n compress: {\n toplevel: true,\n hoist_props: false\n }\n }\n }\n };\n }\n\n return minify;\n}\n\nexport function getOptimizationConfig(optimize: OptimizeOption): Optimization | undefined {\n if (optimize === \"readable\") {\n return {\n chunkIds: \"named\",\n moduleIds: \"named\",\n mangleExports: false\n };\n }\n\n if (optimize === false) {\n // Doesn't turn off everything but is good enough to help with debugging scenarios.\n return {\n chunkIds: \"named\",\n moduleIds: \"named\",\n concatenateModules: false,\n mangleExports: false,\n usedExports: false\n };\n }\n\n return undefined;\n}\n\nexport function defineBuildConfig(options: DefineBuildConfigOptions = {}) {\n const {\n entry = {\n index: path.resolve(\"./src/index.tsx\")\n },\n distPath = {\n root: path.resolve(\"./dist\")\n },\n assetPrefix = \"/\",\n plugins = [],\n html = defaultDefineHtmlPluginConfig,\n minify = true,\n optimize = true,\n sourceMap = {\n js: \"source-map\",\n css: true\n },\n polyfill = \"usage\",\n splitChunks = {\n preset: \"per-package\",\n chunks: \"all\"\n } satisfies SplitChunksConfig,\n react = defaultDefineReactPluginConfig,\n svgr = defineSvgrPluginConfig,\n compressImage = defineImageCompressPluginConfig,\n // Using an empty object literal as the default value to ensure\n // \"process.env\" is always available.\n environmentVariables = {},\n transformers = [],\n verbose = false\n } = options;\n\n const config: RsbuildConfig = {\n mode: \"production\",\n source: {\n entry,\n // Stringify the environment variables because the plugin does a direct text replacement. Otherwise, \"production\" would become production\n // after replacement and cause an undefined var error because the production var doesn't exist.\n // For more information, view: https://rsbuild.dev/guide/advanced/env-vars#using-define.\n define: {\n \"process.env\": Object.keys(environmentVariables).reduce((acc, key) => {\n acc[key] = JSON.stringify(environmentVariables[key]);\n\n return acc;\n }, {} as Record<string, string>)\n }\n },\n output: {\n target: \"web\",\n distPath,\n cleanDistPath: true,\n assetPrefix,\n minify: getMinifyConfig(optimize, minify),\n sourceMap,\n polyfill\n },\n splitChunks,\n html: html\n ? html({ template: path.resolve(\"./public/index.html\") })\n : undefined,\n plugins: [\n react && pluginReact(react({\n fastRefresh: false\n })),\n svgr && pluginSvgr(svgr({\n svgrOptions: {\n exportType: \"named\"\n }\n })),\n compressImage && pluginImageCompress(compressImage([\"jpeg\", \"png\", \"ico\", \"svg\"])),\n ...plugins\n ].filter(Boolean),\n tools: {\n rspack: {\n optimization: getOptimizationConfig(optimize),\n infrastructureLogging: verbose ? {\n appendOnly: true,\n level: \"verbose\",\n debug: /PackFileCache/\n } : undefined\n }\n }\n };\n\n const transformedConfig = applyTransformers(config, transformers, {\n environment: \"build\",\n verbose\n });\n\n return defineConfig(transformedConfig);\n}\n"],"names":["defineConfig","pluginImageCompress","pluginReact","pluginSvgr","path","applyTransformers","defaultDefineHtmlPluginConfig","options","defaultDefineReactPluginConfig","defineSvgrPluginConfig","defineImageCompressPluginConfig","getMinifyConfig","optimize","minify","getOptimizationConfig","undefined","defineBuildConfig","entry","distPath","assetPrefix","plugins","html","sourceMap","polyfill","splitChunks","react","svgr","compressImage","environmentVariables","transformers","verbose","config","Object","acc","key","JSON","Boolean","transformedConfig"],"mappings":"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"}
|
package/dist/dev.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface DefineDevConfigOptions {
|
|
|
21
21
|
sourceMap?: false | SourceMap;
|
|
22
22
|
overlay?: false;
|
|
23
23
|
writeToDisk?: true;
|
|
24
|
+
setup?: ServerConfig["setup"];
|
|
24
25
|
react?: false | DefineDevDefineReactPluginConfigFunction;
|
|
25
26
|
svgr?: false | DefineDevSvgrPluginConfigFunction;
|
|
26
27
|
environmentVariables?: Record<string, unknown>;
|
package/dist/dev.js
CHANGED
|
@@ -35,7 +35,7 @@ function defineDevConfig(options = {}) {
|
|
|
35
35
|
}, https = false, host = "localhost", port = 8080, assetPrefix = "/", plugins = [], html = defaultDefineHtmlPluginConfig, lazyCompilation = false, hmr = true, fastRefresh = true, sourceMap = {
|
|
36
36
|
js: "cheap-module-source-map",
|
|
37
37
|
css: true
|
|
38
|
-
}, overlay, writeToDisk, react = defaultDefineReactPluginConfig, svgr = defineSvgrPluginConfig, // Using an empty object literal as the default value to ensure
|
|
38
|
+
}, overlay, writeToDisk, setup, react = defaultDefineReactPluginConfig, svgr = defineSvgrPluginConfig, // Using an empty object literal as the default value to ensure
|
|
39
39
|
// "process.env" is always available.
|
|
40
40
|
environmentVariables = {}, transformers = [], verbose = false } = options;
|
|
41
41
|
const config = {
|
|
@@ -44,7 +44,7 @@ function defineDevConfig(options = {}) {
|
|
|
44
44
|
assetPrefix,
|
|
45
45
|
lazyCompilation,
|
|
46
46
|
hmr: hmr || fastRefresh,
|
|
47
|
-
client: overlay === false
|
|
47
|
+
client: overlay === false ? {
|
|
48
48
|
overlay: false
|
|
49
49
|
} : undefined,
|
|
50
50
|
writeToDisk
|
|
@@ -53,7 +53,8 @@ function defineDevConfig(options = {}) {
|
|
|
53
53
|
https: isBoolean(https) || isFunction(https) ? undefined : https,
|
|
54
54
|
host,
|
|
55
55
|
port,
|
|
56
|
-
historyApiFallback: true
|
|
56
|
+
historyApiFallback: true,
|
|
57
|
+
setup
|
|
57
58
|
},
|
|
58
59
|
source: {
|
|
59
60
|
entry,
|
|
@@ -78,10 +79,7 @@ function defineDevConfig(options = {}) {
|
|
|
78
79
|
plugins: [
|
|
79
80
|
https && (isBoolean(https) || isFunction(https)) && pluginBasicSsl(isFunction(https) ? https({}) : undefined),
|
|
80
81
|
react && pluginReact(react({
|
|
81
|
-
fastRefresh
|
|
82
|
-
reactRefreshOptions: {
|
|
83
|
-
overlay: overlay !== false
|
|
84
|
-
}
|
|
82
|
+
fastRefresh
|
|
85
83
|
})),
|
|
86
84
|
svgr && pluginSvgr(svgr({
|
|
87
85
|
svgrOptions: {
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sources":["../src/dev.ts"],"sourcesContent":["import { defineConfig, type HtmlConfig, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type ServerConfig, type SourceMap } from \"@rsbuild/core\";\nimport { pluginBasicSsl, type PluginBasicSslOptions } from \"@rsbuild/plugin-basic-ssl\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport path from \"node:path\";\nimport { applyTransformers, type RsbuildConfigTransformer } from \"./applyTransformers.ts\";\nimport { isBoolean, isFunction } from \"./assertions.ts\";\n\nexport type DefineDevHtmlPluginConfigFunction = (defaultOptions: HtmlConfig) => HtmlConfig;\nexport type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\nexport type DefineBasicSslConfigFunction = (defaultOptions: PluginBasicSslOptions) => PluginBasicSslOptions;\n\nexport interface DefineDevConfigOptions {\n entry?: RsbuildEntry;\n https?: boolean | DefineBasicSslConfigFunction | ServerConfig[\"https\"];\n host?: string;\n port?: number;\n // Similar to webpack.publicPath.\n assetPrefix?: string;\n plugins?: RsbuildPlugins;\n html?: false | DefineDevHtmlPluginConfigFunction;\n lazyCompilation?: boolean;\n hmr?: boolean;\n fastRefresh?: boolean;\n sourceMap?: false | SourceMap;\n overlay?: false;\n writeToDisk?: true;\n react?: false | DefineDevDefineReactPluginConfigFunction;\n svgr?: false | DefineDevSvgrPluginConfigFunction;\n environmentVariables?: Record<string, unknown>;\n transformers?: RsbuildConfigTransformer[];\n verbose?: boolean;\n}\n\nfunction defaultDefineHtmlPluginConfig(options: HtmlConfig) {\n return options;\n}\n\nfunction defaultDefineReactPluginConfig(options: PluginReactOptions) {\n return options;\n}\n\nfunction defineSvgrPluginConfig(options: PluginSvgrOptions) {\n return options;\n}\n\nexport function defineDevConfig(options: DefineDevConfigOptions = {}) {\n const {\n entry = {\n index: path.resolve(\"./src/index.tsx\")\n },\n https = false,\n host = \"localhost\",\n port = 8080,\n assetPrefix = \"/\",\n plugins = [],\n html = defaultDefineHtmlPluginConfig,\n lazyCompilation = false,\n hmr = true,\n fastRefresh = true,\n sourceMap = {\n js: \"cheap-module-source-map\",\n css: true\n },\n overlay,\n writeToDisk,\n react = defaultDefineReactPluginConfig,\n svgr = defineSvgrPluginConfig,\n // Using an empty object literal as the default value to ensure\n // \"process.env\" is always available.\n environmentVariables = {},\n transformers = [],\n verbose = false\n } = options;\n\n const config: RsbuildConfig = {\n mode: \"development\",\n dev: {\n assetPrefix,\n lazyCompilation,\n hmr: hmr || fastRefresh,\n client:
|
|
1
|
+
{"version":3,"file":"dev.js","sources":["../src/dev.ts"],"sourcesContent":["import { defineConfig, type HtmlConfig, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type ServerConfig, type SourceMap } from \"@rsbuild/core\";\nimport { pluginBasicSsl, type PluginBasicSslOptions } from \"@rsbuild/plugin-basic-ssl\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport path from \"node:path\";\nimport { applyTransformers, type RsbuildConfigTransformer } from \"./applyTransformers.ts\";\nimport { isBoolean, isFunction } from \"./assertions.ts\";\n\nexport type DefineDevHtmlPluginConfigFunction = (defaultOptions: HtmlConfig) => HtmlConfig;\nexport type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\nexport type DefineBasicSslConfigFunction = (defaultOptions: PluginBasicSslOptions) => PluginBasicSslOptions;\n\nexport interface DefineDevConfigOptions {\n entry?: RsbuildEntry;\n https?: boolean | DefineBasicSslConfigFunction | ServerConfig[\"https\"];\n host?: string;\n port?: number;\n // Similar to webpack.publicPath.\n assetPrefix?: string;\n plugins?: RsbuildPlugins;\n html?: false | DefineDevHtmlPluginConfigFunction;\n lazyCompilation?: boolean;\n hmr?: boolean;\n fastRefresh?: boolean;\n sourceMap?: false | SourceMap;\n overlay?: false;\n writeToDisk?: true;\n setup?: ServerConfig[\"setup\"];\n react?: false | DefineDevDefineReactPluginConfigFunction;\n svgr?: false | DefineDevSvgrPluginConfigFunction;\n environmentVariables?: Record<string, unknown>;\n transformers?: RsbuildConfigTransformer[];\n verbose?: boolean;\n}\n\nfunction defaultDefineHtmlPluginConfig(options: HtmlConfig) {\n return options;\n}\n\nfunction defaultDefineReactPluginConfig(options: PluginReactOptions) {\n return options;\n}\n\nfunction defineSvgrPluginConfig(options: PluginSvgrOptions) {\n return options;\n}\n\nexport function defineDevConfig(options: DefineDevConfigOptions = {}) {\n const {\n entry = {\n index: path.resolve(\"./src/index.tsx\")\n },\n https = false,\n host = \"localhost\",\n port = 8080,\n assetPrefix = \"/\",\n plugins = [],\n html = defaultDefineHtmlPluginConfig,\n lazyCompilation = false,\n hmr = true,\n fastRefresh = true,\n sourceMap = {\n js: \"cheap-module-source-map\",\n css: true\n },\n overlay,\n writeToDisk,\n setup,\n react = defaultDefineReactPluginConfig,\n svgr = defineSvgrPluginConfig,\n // Using an empty object literal as the default value to ensure\n // \"process.env\" is always available.\n environmentVariables = {},\n transformers = [],\n verbose = false\n } = options;\n\n const config: RsbuildConfig = {\n mode: \"development\",\n dev: {\n assetPrefix,\n lazyCompilation,\n hmr: hmr || fastRefresh,\n client: overlay === false ? {\n overlay: false\n } : undefined,\n writeToDisk\n },\n server: {\n https: isBoolean(https) || isFunction(https) ? undefined : https,\n host,\n port,\n historyApiFallback: true,\n setup\n },\n source: {\n entry,\n // Stringify the environment variables because the plugin does a direct text replacement. Otherwise, \"production\" would become production\n // after replacement and cause an undefined var error because the production var doesn't exist.\n // For more information, view: https://rsbuild.dev/guide/advanced/env-vars#using-define.\n define: {\n \"process.env\": Object.keys(environmentVariables).reduce((acc, key) => {\n acc[key] = JSON.stringify(environmentVariables[key]);\n\n return acc;\n }, {} as Record<string, string>)\n }\n },\n output: {\n target: \"web\",\n minify: false,\n sourceMap\n },\n html: html\n ? html({ template: path.resolve(\"./public/index.html\") })\n : undefined,\n plugins: [\n https && (isBoolean(https) || isFunction(https)) && pluginBasicSsl(isFunction(https) ? https({}) : undefined),\n react && pluginReact(react({\n fastRefresh\n })),\n svgr && pluginSvgr(svgr({\n svgrOptions: {\n exportType: \"named\"\n }\n })),\n ...plugins\n ].filter(Boolean),\n tools: {\n rspack: {\n infrastructureLogging: verbose ? {\n appendOnly: true,\n level: \"verbose\",\n debug: /PackFileCache/\n } : undefined\n }\n }\n };\n\n const transformedConfig = applyTransformers(config, transformers, {\n environment: \"dev\",\n verbose\n });\n\n return defineConfig(transformedConfig);\n}\n\n"],"names":["defineConfig","pluginBasicSsl","pluginReact","pluginSvgr","path","applyTransformers","isBoolean","isFunction","defaultDefineHtmlPluginConfig","options","defaultDefineReactPluginConfig","defineSvgrPluginConfig","defineDevConfig","entry","https","host","port","assetPrefix","plugins","html","lazyCompilation","hmr","fastRefresh","sourceMap","overlay","writeToDisk","setup","react","svgr","environmentVariables","transformers","verbose","config","undefined","Object","acc","key","JSON","Boolean","transformedConfig"],"mappings":";;;;;;;;;;;;;;;AAA6J;AACtE;AACV;AACH;AAC7C;AAC6D;AAClC;AA8BxD,SAASQ,6BAA6BA,CAACC,OAAmB;IACtD,OAAOA;AACX;AAEA,SAASC,8BAA8BA,CAACD,OAA2B;IAC/D,OAAOA;AACX;AAEA,SAASE,sBAAsBA,CAACF,OAA0B;IACtD,OAAOA;AACX;AAEO,SAASG,eAAeA,CAACH,UAAkC,CAAC,CAAC;IAChE,MAAM,EACFI,QAAQ;QACJ,OAAOT,iBAAY,CAAC;IACxB,CAAC,EACDU,QAAQ,KAAK,EACbC,OAAO,WAAW,EAClBC,OAAO,IAAI,EACXC,cAAc,GAAG,EACjBC,UAAU,EAAE,EACZC,OAAOX,6BAA6B,EACpCY,kBAAkB,KAAK,EACvBC,MAAM,IAAI,EACVC,cAAc,IAAI,EAClBC,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,OAAO,EACPC,WAAW,EACXC,KAAK,EACLC,QAAQjB,8BAA8B,EACtCkB,OAAOjB,sBAAsB,EAC7B,+DAA+D;IAC/D,qCAAqC;IACrCkB,uBAAuB,CAAC,CAAC,EACzBC,eAAe,EAAE,EACjBC,UAAU,KAAK,EAClB,GAAGtB;IAEJ,MAAMuB,SAAwB;QAC1B,MAAM;QACN,KAAK;YACDf;YACAG;YACA,KAAKC,OAAOC;YACZ,QAAQE,YAAY,QAAQ;gBACxB,SAAS;YACb,IAAIS;YACJR;QACJ;QACA,QAAQ;YACJ,OAAOnB,SAASA,CAACQ,UAAUP,UAAUA,CAACO,SAASmB,YAAYnB;YAC3DC;YACAC;YACA,oBAAoB;YACpBU;QACJ;QACA,QAAQ;YACJb;YACA,yIAAyI;YACzI,+FAA+F;YAC/F,wFAAwF;YACxF,QAAQ;gBACJ,eAAeqB,OAAO,IAAI,CAACL,sBAAsB,MAAM,CAAC,CAACM,KAAKC;oBAC1DD,GAAG,CAACC,IAAI,GAAGC,KAAK,SAAS,CAACR,oBAAoB,CAACO,IAAI;oBAEnD,OAAOD;gBACX,GAAG,CAAC;YACR;QACJ;QACA,QAAQ;YACJ,QAAQ;YACR,QAAQ;YACRZ;QACJ;QACA,MAAMJ,OACAA,KAAK;YAAE,UAAUf,iBAAY,CAAC;QAAuB,KACrD6B;QACN,SAAS;YACLnB,SAAUR,CAAAA,SAASA,CAACQ,UAAUP,UAAUA,CAACO,MAAK,KAAMb,cAAcA,CAACM,UAAUA,CAACO,SAASA,MAAM,CAAC,KAAKmB;YACnGN,SAASzB,WAAWA,CAACyB,MAAM;gBACvBL;YACJ;YACAM,QAAQzB,UAAUA,CAACyB,KAAK;gBACpB,aAAa;oBACT,YAAY;gBAChB;YACJ;eACGV;SACN,CAAC,MAAM,CAACoB;QACT,OAAO;YACH,QAAQ;gBACJ,uBAAuBP,UAAU;oBAC7B,YAAY;oBACZ,OAAO;oBACP,OAAO;gBACX,IAAIE;YACR;QACJ;IACJ;IAEA,MAAMM,oBAAoBlC,iBAAiBA,CAAC2B,QAAQF,cAAc;QAC9D,aAAa;QACbC;IACJ;IAEA,OAAO/B,YAAYA,CAACuC;AACxB"}
|
package/dist/index.js
CHANGED
package/dist/storybook.js
CHANGED
|
@@ -18,7 +18,7 @@ function defineSvgrPluginConfig(options) {
|
|
|
18
18
|
return options;
|
|
19
19
|
}
|
|
20
20
|
function defineStorybookConfig(options = {}) {
|
|
21
|
-
const { plugins = [], lazyCompilation =
|
|
21
|
+
const { plugins = [], lazyCompilation = true, sourceMap = {
|
|
22
22
|
js: "cheap-module-source-map",
|
|
23
23
|
css: true
|
|
24
24
|
}, react = defaultDefineReactPluginConfig, svgr = defineSvgrPluginConfig, // Using an empty object literal as the default value to ensure
|
package/dist/storybook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storybook.js","sources":["../src/storybook.ts"],"sourcesContent":["import { defineConfig, type RsbuildConfig, type RsbuildPlugins, type SourceMap } from \"@rsbuild/core\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport { applyTransformers, type RsbuildConfigTransformer } from \"./applyTransformers.ts\";\n\nexport type DefineStorybookDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineStorybookSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineStorybookConfigOptions {\n plugins?: RsbuildPlugins;\n lazyCompilation?: boolean;\n sourceMap?: boolean | SourceMap;\n react?: false | DefineStorybookDefineReactPluginConfigFunction;\n svgr?: false | DefineStorybookSvgrPluginConfigFunction;\n environmentVariables?: Record<string, unknown>;\n transformers?: RsbuildConfigTransformer[];\n verbose?: boolean;\n}\n\nfunction defaultDefineReactPluginConfig(options: PluginReactOptions) {\n return options;\n}\n\nfunction defineSvgrPluginConfig(options: PluginSvgrOptions) {\n return options;\n}\n\nexport function defineStorybookConfig(options: DefineStorybookConfigOptions = {}) {\n const {\n plugins = [],\n lazyCompilation =
|
|
1
|
+
{"version":3,"file":"storybook.js","sources":["../src/storybook.ts"],"sourcesContent":["import { defineConfig, type RsbuildConfig, type RsbuildPlugins, type SourceMap } from \"@rsbuild/core\";\nimport { pluginReact, type PluginReactOptions } from \"@rsbuild/plugin-react\";\nimport { pluginSvgr, type PluginSvgrOptions } from \"@rsbuild/plugin-svgr\";\nimport { applyTransformers, type RsbuildConfigTransformer } from \"./applyTransformers.ts\";\n\nexport type DefineStorybookDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineStorybookSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineStorybookConfigOptions {\n plugins?: RsbuildPlugins;\n lazyCompilation?: boolean;\n sourceMap?: boolean | SourceMap;\n react?: false | DefineStorybookDefineReactPluginConfigFunction;\n svgr?: false | DefineStorybookSvgrPluginConfigFunction;\n environmentVariables?: Record<string, unknown>;\n transformers?: RsbuildConfigTransformer[];\n verbose?: boolean;\n}\n\nfunction defaultDefineReactPluginConfig(options: PluginReactOptions) {\n return options;\n}\n\nfunction defineSvgrPluginConfig(options: PluginSvgrOptions) {\n return options;\n}\n\nexport function defineStorybookConfig(options: DefineStorybookConfigOptions = {}) {\n const {\n plugins = [],\n lazyCompilation = true,\n sourceMap = {\n js: \"cheap-module-source-map\",\n css: true\n },\n react = defaultDefineReactPluginConfig,\n svgr = defineSvgrPluginConfig,\n // Using an empty object literal as the default value to ensure\n // \"process.env\" is always available.\n environmentVariables = {},\n transformers = [],\n verbose = false\n } = options;\n\n const config: RsbuildConfig = {\n dev: {\n lazyCompilation\n },\n source: {\n // Stringify the environment variables because the plugin does a direct text replacement. Otherwise, \"production\" would become production\n // after replacement and cause an undefined var error because the production var doesn't exist.\n // For more information, view: https://rsbuild.dev/guide/advanced/env-vars#using-define.\n define: {\n \"process.env\": Object.keys(environmentVariables).reduce((acc, key) => {\n acc[key] = JSON.stringify(environmentVariables[key]);\n\n return acc;\n }, {} as Record<string, string>)\n }\n },\n output: {\n target: \"web\",\n minify: false,\n sourceMap\n },\n plugins: [\n react && pluginReact(react({})),\n svgr && pluginSvgr(svgr({\n svgrOptions: {\n exportType: \"named\"\n }\n })),\n ...plugins\n ].filter(Boolean),\n tools: {\n rspack: {\n infrastructureLogging: verbose ? {\n appendOnly: true,\n level: \"verbose\",\n debug: /PackFileCache/\n } : undefined,\n optimization: {\n // Disabling modules concatenation until https://github.com/rstackjs/storybook-rsbuild/issues/403 is fixed.\n concatenateModules: false\n }\n }\n }\n };\n\n const transformedConfig = applyTransformers(config, transformers, {\n environment: \"storybook\",\n verbose\n });\n\n return defineConfig(transformedConfig);\n}\n"],"names":["defineConfig","pluginReact","pluginSvgr","applyTransformers","defaultDefineReactPluginConfig","options","defineSvgrPluginConfig","defineStorybookConfig","plugins","lazyCompilation","sourceMap","react","svgr","environmentVariables","transformers","verbose","config","Object","acc","key","JSON","Boolean","undefined","transformedConfig"],"mappings":";;;;;;;;;AAAsG;AACzB;AACH;AACgB;AAgB1F,SAASI,8BAA8BA,CAACC,OAA2B;IAC/D,OAAOA;AACX;AAEA,SAASC,sBAAsBA,CAACD,OAA0B;IACtD,OAAOA;AACX;AAEO,SAASE,qBAAqBA,CAACF,UAAwC,CAAC,CAAC;IAC5E,MAAM,EACFG,UAAU,EAAE,EACZC,kBAAkB,IAAI,EACtBC,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,QAAQP,8BAA8B,EACtCQ,OAAON,sBAAsB,EAC7B,+DAA+D;IAC/D,qCAAqC;IACrCO,uBAAuB,CAAC,CAAC,EACzBC,eAAe,EAAE,EACjBC,UAAU,KAAK,EAClB,GAAGV;IAEJ,MAAMW,SAAwB;QAC1B,KAAK;YACDP;QACJ;QACA,QAAQ;YACJ,yIAAyI;YACzI,+FAA+F;YAC/F,wFAAwF;YACxF,QAAQ;gBACJ,eAAeQ,OAAO,IAAI,CAACJ,sBAAsB,MAAM,CAAC,CAACK,KAAKC;oBAC1DD,GAAG,CAACC,IAAI,GAAGC,KAAK,SAAS,CAACP,oBAAoB,CAACM,IAAI;oBAEnD,OAAOD;gBACX,GAAG,CAAC;YACR;QACJ;QACA,QAAQ;YACJ,QAAQ;YACR,QAAQ;YACRR;QACJ;QACA,SAAS;YACLC,SAASV,WAAWA,CAACU,MAAM,CAAC;YAC5BC,QAAQV,UAAUA,CAACU,KAAK;gBACpB,aAAa;oBACT,YAAY;gBAChB;YACJ;eACGJ;SACN,CAAC,MAAM,CAACa;QACT,OAAO;YACH,QAAQ;gBACJ,uBAAuBN,UAAU;oBAC7B,YAAY;oBACZ,OAAO;oBACP,OAAO;gBACX,IAAIO;gBACJ,cAAc;oBACV,2GAA2G;oBAC3G,oBAAoB;gBACxB;YACJ;QACJ;IACJ;IAEA,MAAMC,oBAAoBpB,iBAAiBA,CAACa,QAAQF,cAAc;QAC9D,aAAa;QACbC;IACJ;IAEA,OAAOf,YAAYA,CAACuB;AACxB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@workleap/rsbuild-configs",
|
|
3
3
|
"author": "Workleap",
|
|
4
4
|
"description": "Workleap recommended Rsbuild configurations.",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "4.1.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -28,30 +28,31 @@
|
|
|
28
28
|
"CHANGELOG.md"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@rsbuild/core": "^
|
|
32
|
-
"@rspack/core": "^
|
|
31
|
+
"@rsbuild/core": "^2.0.5",
|
|
32
|
+
"@rspack/core": "^2.0.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@rsbuild/plugin-basic-ssl": "^1.2.2",
|
|
36
|
-
"@rsbuild/plugin-image-compress": "^1.3.
|
|
37
|
-
"@rsbuild/plugin-react": "^
|
|
38
|
-
"@rsbuild/plugin-svgr": "^
|
|
36
|
+
"@rsbuild/plugin-image-compress": "^1.3.3",
|
|
37
|
+
"@rsbuild/plugin-react": "^2.0.0",
|
|
38
|
+
"@rsbuild/plugin-svgr": "^2.0.2",
|
|
39
|
+
"core-js": "^3.49.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@eslint/js": "9.39.2",
|
|
42
|
-
"@rsbuild/core": "
|
|
43
|
-
"@rslib/core": "0.
|
|
44
|
-
"@rspack/core": "
|
|
45
|
-
"@types/node": "25.
|
|
46
|
-
"@typescript-eslint/parser": "8.
|
|
47
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
43
|
+
"@rsbuild/core": "2.0.5",
|
|
44
|
+
"@rslib/core": "0.21.4",
|
|
45
|
+
"@rspack/core": "2.0.3",
|
|
46
|
+
"@types/node": "25.7.0",
|
|
47
|
+
"@typescript-eslint/parser": "8.59.3",
|
|
48
|
+
"@typescript/native-preview": "7.0.0-dev.20260512.1",
|
|
48
49
|
"eslint": "9.39.2",
|
|
49
|
-
"typescript": "6.0.
|
|
50
|
-
"typescript-eslint": "8.
|
|
51
|
-
"vitest": "4.1.
|
|
52
|
-
"@workleap/
|
|
53
|
-
"@workleap/
|
|
54
|
-
"@workleap/typescript-configs": "4.0.
|
|
50
|
+
"typescript": "6.0.3",
|
|
51
|
+
"typescript-eslint": "8.59.3",
|
|
52
|
+
"vitest": "4.1.6",
|
|
53
|
+
"@workleap/rslib-configs": "1.2.0",
|
|
54
|
+
"@workleap/eslint-configs": "2.0.3",
|
|
55
|
+
"@workleap/typescript-configs": "4.0.2"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"build": "rslib build -c rslib.config.ts",
|
package/src/build.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineConfig, type DistPathConfig, type HtmlConfig, type Minify, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type SourceMap } from "@rsbuild/core";
|
|
1
|
+
import { defineConfig, type DistPathConfig, type HtmlConfig, type Minify, type Polyfill, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type SourceMap, type SplitChunksConfig } from "@rsbuild/core";
|
|
2
2
|
import { pluginImageCompress, type PluginImageCompressOptions } from "@rsbuild/plugin-image-compress";
|
|
3
3
|
import { pluginReact, type PluginReactOptions } from "@rsbuild/plugin-react";
|
|
4
4
|
import { pluginSvgr, type PluginSvgrOptions } from "@rsbuild/plugin-svgr";
|
|
5
|
-
import {
|
|
5
|
+
import type { Optimization } from "@rspack/core";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { applyTransformers, type RsbuildConfigTransformer } from "./applyTransformers.ts";
|
|
8
8
|
|
|
@@ -24,6 +24,8 @@ export interface DefineBuildConfigOptions {
|
|
|
24
24
|
minify?: Minify;
|
|
25
25
|
optimize?: OptimizeOption;
|
|
26
26
|
sourceMap?: boolean | SourceMap;
|
|
27
|
+
polyfill?: Polyfill;
|
|
28
|
+
splitChunks?: SplitChunksConfig | false;
|
|
27
29
|
react?: false | DefineBuildDefineReactPluginConfigFunction;
|
|
28
30
|
svgr?: false | DefineBuildSvgrPluginConfigFunction;
|
|
29
31
|
compressImage?: false | DefineBuildImageCompressPluginConfigFunction;
|
|
@@ -48,41 +50,49 @@ function defineImageCompressPluginConfig(options: PluginImageCompressOptions) {
|
|
|
48
50
|
return options;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
if (optimize ===
|
|
53
|
+
function getMinifyConfig(optimize: OptimizeOption, minify: Minify): Minify {
|
|
54
|
+
if (optimize === false) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (optimize === "readable") {
|
|
53
59
|
return {
|
|
54
|
-
|
|
60
|
+
jsOptions: {
|
|
61
|
+
minimizerOptions: {
|
|
62
|
+
mangle: false,
|
|
63
|
+
compress: {
|
|
64
|
+
toplevel: true,
|
|
65
|
+
hoist_props: false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
55
69
|
};
|
|
56
|
-
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return minify;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function getOptimizationConfig(optimize: OptimizeOption): Optimization | undefined {
|
|
76
|
+
if (optimize === "readable") {
|
|
57
77
|
return {
|
|
58
|
-
minimize: true,
|
|
59
|
-
minimizer: [
|
|
60
|
-
new SwcJsMinimizerRspackPlugin({
|
|
61
|
-
minimizerOptions: {
|
|
62
|
-
mangle: false,
|
|
63
|
-
compress: {
|
|
64
|
-
toplevel: true,
|
|
65
|
-
hoist_props: false
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
],
|
|
70
78
|
chunkIds: "named",
|
|
71
79
|
moduleIds: "named",
|
|
72
80
|
mangleExports: false
|
|
73
81
|
};
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
84
|
+
if (optimize === false) {
|
|
85
|
+
// Doesn't turn off everything but is good enough to help with debugging scenarios.
|
|
86
|
+
return {
|
|
87
|
+
chunkIds: "named",
|
|
88
|
+
moduleIds: "named",
|
|
89
|
+
concatenateModules: false,
|
|
90
|
+
mangleExports: false,
|
|
91
|
+
usedExports: false
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return undefined;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
@@ -102,6 +112,11 @@ export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
|
102
112
|
js: "source-map",
|
|
103
113
|
css: true
|
|
104
114
|
},
|
|
115
|
+
polyfill = "usage",
|
|
116
|
+
splitChunks = {
|
|
117
|
+
preset: "per-package",
|
|
118
|
+
chunks: "all"
|
|
119
|
+
} satisfies SplitChunksConfig,
|
|
105
120
|
react = defaultDefineReactPluginConfig,
|
|
106
121
|
svgr = defineSvgrPluginConfig,
|
|
107
122
|
compressImage = defineImageCompressPluginConfig,
|
|
@@ -132,9 +147,11 @@ export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
|
132
147
|
distPath,
|
|
133
148
|
cleanDistPath: true,
|
|
134
149
|
assetPrefix,
|
|
135
|
-
minify,
|
|
136
|
-
sourceMap
|
|
150
|
+
minify: getMinifyConfig(optimize, minify),
|
|
151
|
+
sourceMap,
|
|
152
|
+
polyfill
|
|
137
153
|
},
|
|
154
|
+
splitChunks,
|
|
138
155
|
html: html
|
|
139
156
|
? html({ template: path.resolve("./public/index.html") })
|
|
140
157
|
: undefined,
|
package/src/dev.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface DefineDevConfigOptions {
|
|
|
26
26
|
sourceMap?: false | SourceMap;
|
|
27
27
|
overlay?: false;
|
|
28
28
|
writeToDisk?: true;
|
|
29
|
+
setup?: ServerConfig["setup"];
|
|
29
30
|
react?: false | DefineDevDefineReactPluginConfigFunction;
|
|
30
31
|
svgr?: false | DefineDevSvgrPluginConfigFunction;
|
|
31
32
|
environmentVariables?: Record<string, unknown>;
|
|
@@ -65,6 +66,7 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
65
66
|
},
|
|
66
67
|
overlay,
|
|
67
68
|
writeToDisk,
|
|
69
|
+
setup,
|
|
68
70
|
react = defaultDefineReactPluginConfig,
|
|
69
71
|
svgr = defineSvgrPluginConfig,
|
|
70
72
|
// Using an empty object literal as the default value to ensure
|
|
@@ -80,7 +82,7 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
80
82
|
assetPrefix,
|
|
81
83
|
lazyCompilation,
|
|
82
84
|
hmr: hmr || fastRefresh,
|
|
83
|
-
client:
|
|
85
|
+
client: overlay === false ? {
|
|
84
86
|
overlay: false
|
|
85
87
|
} : undefined,
|
|
86
88
|
writeToDisk
|
|
@@ -89,7 +91,8 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
89
91
|
https: isBoolean(https) || isFunction(https) ? undefined : https,
|
|
90
92
|
host,
|
|
91
93
|
port,
|
|
92
|
-
historyApiFallback: true
|
|
94
|
+
historyApiFallback: true,
|
|
95
|
+
setup
|
|
93
96
|
},
|
|
94
97
|
source: {
|
|
95
98
|
entry,
|
|
@@ -115,10 +118,7 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
115
118
|
plugins: [
|
|
116
119
|
https && (isBoolean(https) || isFunction(https)) && pluginBasicSsl(isFunction(https) ? https({}) : undefined),
|
|
117
120
|
react && pluginReact(react({
|
|
118
|
-
fastRefresh
|
|
119
|
-
reactRefreshOptions: {
|
|
120
|
-
overlay: overlay !== false
|
|
121
|
-
}
|
|
121
|
+
fastRefresh
|
|
122
122
|
})),
|
|
123
123
|
svgr && pluginSvgr(svgr({
|
|
124
124
|
svgrOptions: {
|
package/src/storybook.ts
CHANGED
|
@@ -28,7 +28,7 @@ function defineSvgrPluginConfig(options: PluginSvgrOptions) {
|
|
|
28
28
|
export function defineStorybookConfig(options: DefineStorybookConfigOptions = {}) {
|
|
29
29
|
const {
|
|
30
30
|
plugins = [],
|
|
31
|
-
lazyCompilation =
|
|
31
|
+
lazyCompilation = true,
|
|
32
32
|
sourceMap = {
|
|
33
33
|
js: "cheap-module-source-map",
|
|
34
34
|
css: true
|