@workleap/rsbuild-configs 2.0.0 → 3.0.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 +12 -0
- package/dist/build.js +10 -10
- package/dist/build.js.map +1 -1
- package/dist/dev.js +3 -2
- package/dist/dev.js.map +1 -1
- package/package.json +2 -2
- package/src/build.ts +10 -10
- package/src/dev.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @workleap/rsbuild-configs
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#258](https://github.com/workleap/wl-web-configs/pull/258) [`c562227`](https://github.com/workleap/wl-web-configs/commit/c562227c82d2b87a86fc6141d5eb18f9ece97fca) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Production bundle filenames now includes an hash.
|
|
8
|
+
|
|
9
|
+
## 2.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#254](https://github.com/workleap/wl-web-configs/pull/254) [`b3a6ddf`](https://github.com/workleap/wl-web-configs/commit/b3a6ddfcb60e0f5d43b44f971601220ad17249ab) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Change rsbuild dev config default `assetPrefix` value to `/`.
|
|
14
|
+
|
|
3
15
|
## 2.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/build.js
CHANGED
|
@@ -105,16 +105,16 @@ function defineBuildConfig(options = {}) {
|
|
|
105
105
|
distPath,
|
|
106
106
|
cleanDistPath: true,
|
|
107
107
|
assetPrefix,
|
|
108
|
-
filename: {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
108
|
+
// filename: {
|
|
109
|
+
// html: "[name].html",
|
|
110
|
+
// js: "[name].js",
|
|
111
|
+
// css: "[name].css",
|
|
112
|
+
// svg: "[name].[contenthash:8].svg",
|
|
113
|
+
// font: "[name].[contenthash:8][ext]",
|
|
114
|
+
// image: "[name].[contenthash:8][ext]",
|
|
115
|
+
// media: "[name].[contenthash:8][ext]",
|
|
116
|
+
// assets: "[name].[contenthash:8][ext]"
|
|
117
|
+
// },
|
|
118
118
|
minify,
|
|
119
119
|
sourceMap
|
|
120
120
|
},
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["webpack://@workleap/rsbuild-configs/./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 { SwcJsMinimizerRspackPlugin, 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 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\nexport function getOptimizationConfig(optimize: OptimizeOption): Optimization {\n if (optimize === true) {\n return {\n minimize: true\n };\n } else if (optimize === \"readable\") {\n return {\n minimize: true,\n minimizer: [\n new SwcJsMinimizerRspackPlugin({\n minimizerOptions: {\n mangle: false,\n compress: {\n toplevel: true,\n hoist_props: false\n }\n }\n })\n ],\n chunkIds: \"named\",\n moduleIds: \"named\",\n mangleExports: false\n };\n }\n\n // Doesn't turnoff everything but is good enough to help with debugging scenarios.\n return {\n minimize: false,\n chunkIds: \"named\",\n moduleIds: \"named\",\n concatenateModules: false,\n mangleExports: false,\n removeAvailableModules: false,\n usedExports: false\n };\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 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 filename: {\n
|
|
1
|
+
{"version":3,"file":"build.js","sources":["webpack://@workleap/rsbuild-configs/./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 { SwcJsMinimizerRspackPlugin, 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 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\nexport function getOptimizationConfig(optimize: OptimizeOption): Optimization {\n if (optimize === true) {\n return {\n minimize: true\n };\n } else if (optimize === \"readable\") {\n return {\n minimize: true,\n minimizer: [\n new SwcJsMinimizerRspackPlugin({\n minimizerOptions: {\n mangle: false,\n compress: {\n toplevel: true,\n hoist_props: false\n }\n }\n })\n ],\n chunkIds: \"named\",\n moduleIds: \"named\",\n mangleExports: false\n };\n }\n\n // Doesn't turnoff everything but is good enough to help with debugging scenarios.\n return {\n minimize: false,\n chunkIds: \"named\",\n moduleIds: \"named\",\n concatenateModules: false,\n mangleExports: false,\n removeAvailableModules: false,\n usedExports: false\n };\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 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 // filename: {\n // html: \"[name].html\",\n // js: \"[name].js\",\n // css: \"[name].css\",\n // svg: \"[name].[contenthash:8].svg\",\n // font: \"[name].[contenthash:8][ext]\",\n // image: \"[name].[contenthash:8][ext]\",\n // media: \"[name].[contenthash:8][ext]\",\n // assets: \"[name].[contenthash:8][ext]\"\n // },\n minify,\n sourceMap\n },\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","SwcJsMinimizerRspackPlugin","path","applyTransformers","defaultDefineHtmlPluginConfig","options","defaultDefineReactPluginConfig","defineSvgrPluginConfig","defineImageCompressPluginConfig","getOptimizationConfig","optimize","defineBuildConfig","entry","distPath","assetPrefix","plugins","html","minify","sourceMap","react","svgr","compressImage","environmentVariables","transformers","verbose","config","Object","acc","key","JSON","undefined","Boolean","transformedConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA4K;AACtE;AACzB;AACH;AACG;AAChD;AAC6D;AA4B1F,SAASO,8BAA8BC,OAAmB;IACtD,OAAOA;AACX;AAEA,SAASC,+BAA+BD,OAA2B;IAC/D,OAAOA;AACX;AAEA,SAASE,uBAAuBF,OAA0B;IACtD,OAAOA;AACX;AAEA,SAASG,gCAAgCH,OAAmC;IACxE,OAAOA;AACX;AAEO,SAASI,sBAAsBC,QAAwB;IAC1D,IAAIA,aAAa,MAAM;QACnB,OAAO;YACH,UAAU;QACd;IACJ,OAAO,IAAIA,aAAa,YAAY;QAChC,OAAO;YACH,UAAU;YACV,WAAW;gBACP,IAAIT,4EAA0BA,CAAC;oBAC3B,kBAAkB;wBACd,QAAQ;wBACR,UAAU;4BACN,UAAU;4BACV,aAAa;wBACjB;oBACJ;gBACJ;aACH;YACD,UAAU;YACV,WAAW;YACX,eAAe;QACnB;IACJ;IAEA,kFAAkF;IAClF,OAAO;QACH,UAAU;QACV,UAAU;QACV,WAAW;QACX,oBAAoB;QACpB,eAAe;QACf,wBAAwB;QACxB,aAAa;IACjB;AACJ;AAEO,SAASU,kBAAkBN,UAAoC,CAAC,CAAC;IACpE,MAAM,EACFO,QAAQ;QACJ,OAAOV,iEAAY,CAAC;IACxB,CAAC,EACDW,WAAW;QACP,MAAMX,iEAAY,CAAC;IACvB,CAAC,EACDY,cAAc,GAAG,EACjBC,UAAU,EAAE,EACZC,OAAOZ,6BAA6B,EACpCa,SAAS,IAAI,EACbP,WAAW,IAAI,EACfQ,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,QAAQb,8BAA8B,EACtCc,OAAOb,sBAAsB,EAC7Bc,gBAAgBb,+BAA+B,EAC/C,+DAA+D;IAC/D,qCAAqC;IACrCc,uBAAuB,CAAC,CAAC,EACzBC,eAAe,EAAE,EACjBC,UAAU,KAAK,EAClB,GAAGnB;IAEJ,MAAMoB,SAAwB;QAC1B,MAAM;QACN,QAAQ;YACJb;YACA,yIAAyI;YACzI,+FAA+F;YAC/F,wFAAwF;YACxF,QAAQ;gBACJ,eAAec,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;YACRd;YACA,eAAe;YACfC;YACA,cAAc;YACd,2BAA2B;YAC3B,uBAAuB;YACvB,yBAAyB;YACzB,yCAAyC;YACzC,2CAA2C;YAC3C,4CAA4C;YAC5C,4CAA4C;YAC5C,4CAA4C;YAC5C,KAAK;YACLG;YACAC;QACJ;QACA,MAAMF,OACAA,KAAK;YAAE,UAAUd,iEAAY,CAAC;QAAuB,KACrD4B;QACN,SAAS;YACLX,SAASpB,0EAAWA,CAACoB,MAAM;gBACvB,aAAa;YACjB;YACAC,QAAQpB,wEAAUA,CAACoB,KAAK;gBACpB,aAAa;oBACT,YAAY;gBAChB;YACJ;YACAC,iBAAiBvB,2FAAmBA,CAACuB,cAAc;gBAAC;gBAAQ;gBAAO;gBAAO;aAAM;eAC7EN;SACN,CAAC,MAAM,CAACgB;QACT,OAAO;YACH,QAAQ;gBACJ,cAActB,sBAAsBC;gBACpC,uBAAuBc,UAAU;oBAC7B,YAAY;oBACZ,OAAO;oBACP,OAAO;gBACX,IAAIM;YACR;QACJ;IACJ;IAEA,MAAME,oBAAoB7B,gFAAiBA,CAACsB,QAAQF,cAAc;QAC9D,aAAa;QACbC;IACJ;IAEA,OAAO3B,mEAAYA,CAACmC;AACxB"}
|
package/dist/dev.js
CHANGED
|
@@ -40,7 +40,7 @@ function defineSvgrPluginConfig(options) {
|
|
|
40
40
|
function defineDevConfig(options = {}) {
|
|
41
41
|
const { entry = {
|
|
42
42
|
index: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve("./src/index.tsx")
|
|
43
|
-
}, https = false, host = "localhost", port = 8080, assetPrefix, plugins = [], html = defaultDefineHtmlPluginConfig, lazyCompilation = true, hmr = true, fastRefresh = true, sourceMap = {
|
|
43
|
+
}, https = false, host = "localhost", port = 8080, assetPrefix = "/", plugins = [], html = defaultDefineHtmlPluginConfig, lazyCompilation = true, hmr = true, fastRefresh = true, sourceMap = {
|
|
44
44
|
js: "cheap-module-source-map",
|
|
45
45
|
css: true
|
|
46
46
|
}, overlay, writeToDisk, react = defaultDefineReactPluginConfig, svgr = defineSvgrPluginConfig, // Using an empty object literal as the default value to ensure
|
|
@@ -49,7 +49,8 @@ function defineDevConfig(options = {}) {
|
|
|
49
49
|
const config = {
|
|
50
50
|
mode: "development",
|
|
51
51
|
dev: {
|
|
52
|
-
assetPrefix: assetPrefix ?? `${https ? "https" : "http"}://${host}:${port}`,
|
|
52
|
+
// assetPrefix: assetPrefix ?? `${https ? "https" : "http"}://${host}:${port}`,
|
|
53
|
+
assetPrefix,
|
|
53
54
|
lazyCompilation,
|
|
54
55
|
hmr: hmr || fastRefresh,
|
|
55
56
|
client: overlay === false || fastRefresh ? {
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sources":["webpack://@workleap/rsbuild-configs/./src/dev.ts"],"sourcesContent":["import { defineConfig, type HtmlConfig, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type ServerConfig, type SourceMap } from \"@rsbuild/core\";\nimport { pluginBasicSsl } 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 } from \"./assertions.ts\";\n\nexport type DefineDevHtmlPluginConfigFunction = (defaultOptions: HtmlConfig) => HtmlConfig;\nexport type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineDevConfigOptions {\n entry?: RsbuildEntry;\n https?: boolean | 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 = true,\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: assetPrefix ?? `${https ? \"https\" : \"http\"}://${host}:${port}`,\n lazyCompilation,\n hmr: hmr || fastRefresh,\n client: (overlay === false || fastRefresh) ? {\n overlay: false\n } : undefined,\n writeToDisk\n },\n server: {\n https: isBoolean(https) ? undefined : https,\n host,\n port,\n historyApiFallback: true\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 isBoolean(https) && https && pluginBasicSsl(),\n react && pluginReact(react({\n fastRefresh,\n reactRefreshOptions: {\n overlay: overlay !== false\n }\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","defaultDefineHtmlPluginConfig","options","defaultDefineReactPluginConfig","defineSvgrPluginConfig","defineDevConfig","entry","https","host","port","assetPrefix","plugins","html","lazyCompilation","hmr","fastRefresh","sourceMap","overlay","writeToDisk","react","svgr","environmentVariables","transformers","verbose","config","undefined","Object","acc","key","JSON","Boolean","transformedConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA6J;AAClG;AACkB;AACH;AAC7C;AAC6D;AAC9C;AA4B5C,SAASO,8BAA8BC,OAAmB;IACtD,OAAOA;AACX;AAEA,SAASC,+BAA+BD,OAA2B;IAC/D,OAAOA;AACX;AAEA,SAASE,uBAAuBF,OAA0B;IACtD,OAAOA;AACX;AAEO,SAASG,gBAAgBH,UAAkC,CAAC,CAAC;IAChE,MAAM,EACFI,QAAQ;QACJ,OAAOR,iEAAY,CAAC;IACxB,CAAC,EACDS,QAAQ,KAAK,EACbC,OAAO,WAAW,EAClBC,OAAO,IAAI,EACXC,
|
|
1
|
+
{"version":3,"file":"dev.js","sources":["webpack://@workleap/rsbuild-configs/./src/dev.ts"],"sourcesContent":["import { defineConfig, type HtmlConfig, type RsbuildConfig, type RsbuildEntry, type RsbuildPlugins, type ServerConfig, type SourceMap } from \"@rsbuild/core\";\nimport { pluginBasicSsl } 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 } from \"./assertions.ts\";\n\nexport type DefineDevHtmlPluginConfigFunction = (defaultOptions: HtmlConfig) => HtmlConfig;\nexport type DefineDevDefineReactPluginConfigFunction = (defaultOptions: PluginReactOptions) => PluginReactOptions;\nexport type DefineDevSvgrPluginConfigFunction = (defaultOptions: PluginSvgrOptions) => PluginSvgrOptions;\n\nexport interface DefineDevConfigOptions {\n entry?: RsbuildEntry;\n https?: boolean | 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 = true,\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: assetPrefix ?? `${https ? \"https\" : \"http\"}://${host}:${port}`,\n assetPrefix,\n lazyCompilation,\n hmr: hmr || fastRefresh,\n client: (overlay === false || fastRefresh) ? {\n overlay: false\n } : undefined,\n writeToDisk\n },\n server: {\n https: isBoolean(https) ? undefined : https,\n host,\n port,\n historyApiFallback: true\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 isBoolean(https) && https && pluginBasicSsl(),\n react && pluginReact(react({\n fastRefresh,\n reactRefreshOptions: {\n overlay: overlay !== false\n }\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","defaultDefineHtmlPluginConfig","options","defaultDefineReactPluginConfig","defineSvgrPluginConfig","defineDevConfig","entry","https","host","port","assetPrefix","plugins","html","lazyCompilation","hmr","fastRefresh","sourceMap","overlay","writeToDisk","react","svgr","environmentVariables","transformers","verbose","config","undefined","Object","acc","key","JSON","Boolean","transformedConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAA6J;AAClG;AACkB;AACH;AAC7C;AAC6D;AAC9C;AA4B5C,SAASO,8BAA8BC,OAAmB;IACtD,OAAOA;AACX;AAEA,SAASC,+BAA+BD,OAA2B;IAC/D,OAAOA;AACX;AAEA,SAASE,uBAAuBF,OAA0B;IACtD,OAAOA;AACX;AAEO,SAASG,gBAAgBH,UAAkC,CAAC,CAAC;IAChE,MAAM,EACFI,QAAQ;QACJ,OAAOR,iEAAY,CAAC;IACxB,CAAC,EACDS,QAAQ,KAAK,EACbC,OAAO,WAAW,EAClBC,OAAO,IAAI,EACXC,cAAc,GAAG,EACjBC,UAAU,EAAE,EACZC,OAAOX,6BAA6B,EACpCY,kBAAkB,IAAI,EACtBC,MAAM,IAAI,EACVC,cAAc,IAAI,EAClBC,YAAY;QACR,IAAI;QACJ,KAAK;IACT,CAAC,EACDC,OAAO,EACPC,WAAW,EACXC,QAAQhB,8BAA8B,EACtCiB,OAAOhB,sBAAsB,EAC7B,+DAA+D;IAC/D,qCAAqC;IACrCiB,uBAAuB,CAAC,CAAC,EACzBC,eAAe,EAAE,EACjBC,UAAU,KAAK,EAClB,GAAGrB;IAEJ,MAAMsB,SAAwB;QAC1B,MAAM;QACN,KAAK;YACD,+EAA+E;YAC/Ed;YACAG;YACA,KAAKC,OAAOC;YACZ,QAASE,YAAY,SAASF,cAAe;gBACzC,SAAS;YACb,IAAIU;YACJP;QACJ;QACA,QAAQ;YACJ,OAAOlB,iEAASA,CAACO,SAASkB,YAAYlB;YACtCC;YACAC;YACA,oBAAoB;QACxB;QACA,QAAQ;YACJH;YACA,yIAAyI;YACzI,+FAA+F;YAC/F,wFAAwF;YACxF,QAAQ;gBACJ,eAAeoB,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;YACRX;QACJ;QACA,MAAMJ,OACAA,KAAK;YAAE,UAAUd,iEAAY,CAAC;QAAuB,KACrD2B;QACN,SAAS;YACLzB,iEAASA,CAACO,UAAUA,SAASZ,iFAAcA;YAC3CwB,SAASvB,0EAAWA,CAACuB,MAAM;gBACvBJ;gBACA,qBAAqB;oBACjB,SAASE,YAAY;gBACzB;YACJ;YACAG,QAAQvB,wEAAUA,CAACuB,KAAK;gBACpB,aAAa;oBACT,YAAY;gBAChB;YACJ;eACGT;SACN,CAAC,MAAM,CAACmB;QACT,OAAO;YACH,QAAQ;gBACJ,uBAAuBP,UAAU;oBAC7B,YAAY;oBACZ,OAAO;oBACP,OAAO;gBACX,IAAIE;YACR;QACJ;IACJ;IAEA,MAAMM,oBAAoBhC,gFAAiBA,CAACyB,QAAQF,cAAc;QAC9D,aAAa;QACbC;IACJ;IAEA,OAAO7B,mEAAYA,CAACqC;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": "3.0.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"eslint": "8.57.0",
|
|
47
47
|
"typescript": "5.8.2",
|
|
48
48
|
"vitest": "3.1.1",
|
|
49
|
-
"@workleap/eslint-plugin": "3.
|
|
49
|
+
"@workleap/eslint-plugin": "3.4.0",
|
|
50
50
|
"@workleap/rslib-configs": "1.0.4",
|
|
51
51
|
"@workleap/typescript-configs": "3.0.3"
|
|
52
52
|
},
|
package/src/build.ts
CHANGED
|
@@ -132,16 +132,16 @@ export function defineBuildConfig(options: DefineBuildConfigOptions = {}) {
|
|
|
132
132
|
distPath,
|
|
133
133
|
cleanDistPath: true,
|
|
134
134
|
assetPrefix,
|
|
135
|
-
filename: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
},
|
|
135
|
+
// filename: {
|
|
136
|
+
// html: "[name].html",
|
|
137
|
+
// js: "[name].js",
|
|
138
|
+
// css: "[name].css",
|
|
139
|
+
// svg: "[name].[contenthash:8].svg",
|
|
140
|
+
// font: "[name].[contenthash:8][ext]",
|
|
141
|
+
// image: "[name].[contenthash:8][ext]",
|
|
142
|
+
// media: "[name].[contenthash:8][ext]",
|
|
143
|
+
// assets: "[name].[contenthash:8][ext]"
|
|
144
|
+
// },
|
|
145
145
|
minify,
|
|
146
146
|
sourceMap
|
|
147
147
|
},
|
package/src/dev.ts
CHANGED
|
@@ -52,7 +52,7 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
52
52
|
https = false,
|
|
53
53
|
host = "localhost",
|
|
54
54
|
port = 8080,
|
|
55
|
-
assetPrefix,
|
|
55
|
+
assetPrefix = "/",
|
|
56
56
|
plugins = [],
|
|
57
57
|
html = defaultDefineHtmlPluginConfig,
|
|
58
58
|
lazyCompilation = true,
|
|
@@ -76,7 +76,8 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
|
|
|
76
76
|
const config: RsbuildConfig = {
|
|
77
77
|
mode: "development",
|
|
78
78
|
dev: {
|
|
79
|
-
assetPrefix: assetPrefix ?? `${https ? "https" : "http"}://${host}:${port}`,
|
|
79
|
+
// assetPrefix: assetPrefix ?? `${https ? "https" : "http"}://${host}:${port}`,
|
|
80
|
+
assetPrefix,
|
|
80
81
|
lazyCompilation,
|
|
81
82
|
hmr: hmr || fastRefresh,
|
|
82
83
|
client: (overlay === false || fastRefresh) ? {
|