@rsbuild/core 0.7.5 → 0.7.7
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/compiled/css-loader/index.js +20 -20
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +15 -15
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/style-loader/index.js +10 -10
- package/compiled/webpack-dev-middleware/index.js +31 -31
- package/dist/client/hmr.js +10 -6
- package/dist/client/overlay.js +1 -1
- package/dist/index.cjs +100 -62
- package/dist/index.js +118 -78
- package/dist-types/client/format.d.ts +1 -1
- package/dist-types/config.d.ts +2 -1
- package/dist-types/index.d.ts +1 -1
- package/package.json +4 -4
- package/types.d.ts +12 -0
package/dist/client/hmr.js
CHANGED
|
@@ -30,16 +30,16 @@ function hintUnknownFiles(message) {
|
|
|
30
30
|
}
|
|
31
31
|
return message;
|
|
32
32
|
}
|
|
33
|
-
function formatMessage(stats) {
|
|
33
|
+
function formatMessage(stats, verbose) {
|
|
34
34
|
let lines = [];
|
|
35
35
|
let message;
|
|
36
36
|
if (typeof stats === "object") {
|
|
37
37
|
const fileName = resolveFileName(stats);
|
|
38
38
|
const mainMessage = stats.message;
|
|
39
|
-
const details = stats.details ? `
|
|
39
|
+
const details = verbose && stats.details ? `
|
|
40
40
|
Details: ${stats.details}
|
|
41
41
|
` : "";
|
|
42
|
-
const stack = stats.stack ? `
|
|
42
|
+
const stack = verbose && stats.stack ? `
|
|
43
43
|
${stats.stack}` : "";
|
|
44
44
|
message = `${fileName}${mainMessage}${details}${stack}`;
|
|
45
45
|
} else {
|
|
@@ -49,12 +49,16 @@ ${stats.stack}` : "";
|
|
|
49
49
|
lines = message.split("\n");
|
|
50
50
|
lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
|
|
51
51
|
message = lines.join("\n");
|
|
52
|
+
const innerError = "-- inner error --";
|
|
53
|
+
if (!verbose && message.includes(innerError)) {
|
|
54
|
+
message = message.split(innerError)[0];
|
|
55
|
+
}
|
|
52
56
|
return message.trim();
|
|
53
57
|
}
|
|
54
|
-
function formatStatsMessages(stats) {
|
|
58
|
+
function formatStatsMessages(stats, verbose) {
|
|
55
59
|
var _stats_errors, _stats_warnings;
|
|
56
|
-
const formattedErrors = ((_stats_errors = stats.errors) === null || _stats_errors === void 0 ? void 0 : _stats_errors.map(formatMessage)) || [];
|
|
57
|
-
const formattedWarnings = ((_stats_warnings = stats.warnings) === null || _stats_warnings === void 0 ? void 0 : _stats_warnings.map(formatMessage)) || [];
|
|
60
|
+
const formattedErrors = ((_stats_errors = stats.errors) === null || _stats_errors === void 0 ? void 0 : _stats_errors.map((error) => formatMessage(error, verbose))) || [];
|
|
61
|
+
const formattedWarnings = ((_stats_warnings = stats.warnings) === null || _stats_warnings === void 0 ? void 0 : _stats_warnings.map((warning) => formatMessage(warning, verbose))) || [];
|
|
58
62
|
return {
|
|
59
63
|
errors: formattedErrors,
|
|
60
64
|
warnings: formattedWarnings
|
package/dist/client/overlay.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -76,16 +76,16 @@ function hintUnknownFiles(message) {
|
|
|
76
76
|
}
|
|
77
77
|
return message;
|
|
78
78
|
}
|
|
79
|
-
function formatMessage(stats) {
|
|
79
|
+
function formatMessage(stats, verbose) {
|
|
80
80
|
let lines = [];
|
|
81
81
|
let message;
|
|
82
82
|
if (typeof stats === "object") {
|
|
83
83
|
const fileName = resolveFileName(stats);
|
|
84
84
|
const mainMessage = stats.message;
|
|
85
|
-
const details = stats.details ? `
|
|
85
|
+
const details = verbose && stats.details ? `
|
|
86
86
|
Details: ${stats.details}
|
|
87
87
|
` : "";
|
|
88
|
-
const stack = stats.stack ? `
|
|
88
|
+
const stack = verbose && stats.stack ? `
|
|
89
89
|
${stats.stack}` : "";
|
|
90
90
|
message = `${fileName}${mainMessage}${details}${stack}`;
|
|
91
91
|
} else {
|
|
@@ -97,11 +97,15 @@ ${stats.stack}` : "";
|
|
|
97
97
|
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
|
98
98
|
);
|
|
99
99
|
message = lines.join("\n");
|
|
100
|
+
const innerError = "-- inner error --";
|
|
101
|
+
if (!verbose && message.includes(innerError)) {
|
|
102
|
+
message = message.split(innerError)[0];
|
|
103
|
+
}
|
|
100
104
|
return message.trim();
|
|
101
105
|
}
|
|
102
|
-
function formatStatsMessages(stats) {
|
|
103
|
-
const formattedErrors = stats.errors?.map(formatMessage) || [];
|
|
104
|
-
const formattedWarnings = stats.warnings?.map(formatMessage) || [];
|
|
106
|
+
function formatStatsMessages(stats, verbose) {
|
|
107
|
+
const formattedErrors = stats.errors?.map((error) => formatMessage(error, verbose)) || [];
|
|
108
|
+
const formattedWarnings = stats.warnings?.map((warning) => formatMessage(warning, verbose)) || [];
|
|
105
109
|
return {
|
|
106
110
|
errors: formattedErrors,
|
|
107
111
|
warnings: formattedWarnings
|
|
@@ -202,10 +206,14 @@ function formatStats(stats, options = {}) {
|
|
|
202
206
|
...options
|
|
203
207
|
} : options
|
|
204
208
|
);
|
|
205
|
-
const { errors, warnings } = formatStatsMessages(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
const { errors, warnings } = formatStatsMessages(
|
|
210
|
+
{
|
|
211
|
+
errors: getAllStatsErrors(statsData),
|
|
212
|
+
warnings: getAllStatsWarnings(statsData)
|
|
213
|
+
},
|
|
214
|
+
// display verbose messages in prod build or debug mode
|
|
215
|
+
(0, import_shared.isProd)() || (0, import_shared.isDebug)()
|
|
216
|
+
);
|
|
209
217
|
if (stats.hasErrors()) {
|
|
210
218
|
return {
|
|
211
219
|
message: formatErrorMessage(errors),
|
|
@@ -625,7 +633,7 @@ async function stringifyConfig(config, verbose) {
|
|
|
625
633
|
const stringify = import_shared5.RspackChain.toString;
|
|
626
634
|
return stringify(config, { verbose });
|
|
627
635
|
}
|
|
628
|
-
var import_node_fs, import_node_path4, import_shared5, getDefaultDevConfig, getDefaultServerConfig, getDefaultSourceConfig, getDefaultHtmlConfig, getDefaultSecurityConfig, getDefaultToolsConfig, getDefaultPerformanceConfig, getDefaultOutputConfig, createDefaultConfig, withDefaultConfig, normalizeConfig, resolveConfigPath;
|
|
636
|
+
var import_node_fs, import_node_path4, import_shared5, getDefaultDevConfig, getDefaultServerConfig, getDefaultSourceConfig, getDefaultHtmlConfig, getDefaultSecurityConfig, getDefaultToolsConfig, getDefaultPerformanceConfig, getDefaultOutputConfig, createDefaultConfig, withDefaultConfig, normalizeConfig, resolveConfigPath, normalizePublicDirs;
|
|
629
637
|
var init_config = __esm({
|
|
630
638
|
"src/config.ts"() {
|
|
631
639
|
"use strict";
|
|
@@ -652,12 +660,7 @@ var init_config = __esm({
|
|
|
652
660
|
htmlFallback: "index",
|
|
653
661
|
compress: true,
|
|
654
662
|
printUrls: true,
|
|
655
|
-
strictPort: false
|
|
656
|
-
publicDir: {
|
|
657
|
-
name: "public",
|
|
658
|
-
copyOnBuild: true,
|
|
659
|
-
watch: false
|
|
660
|
-
}
|
|
663
|
+
strictPort: false
|
|
661
664
|
});
|
|
662
665
|
getDefaultSourceConfig = () => ({
|
|
663
666
|
alias: {},
|
|
@@ -798,6 +801,31 @@ var init_config = __esm({
|
|
|
798
801
|
}
|
|
799
802
|
return null;
|
|
800
803
|
};
|
|
804
|
+
normalizePublicDirs = (publicDir) => {
|
|
805
|
+
if (publicDir === false) {
|
|
806
|
+
return [];
|
|
807
|
+
}
|
|
808
|
+
const defaultConfig = {
|
|
809
|
+
name: "public",
|
|
810
|
+
copyOnBuild: true,
|
|
811
|
+
watch: false
|
|
812
|
+
};
|
|
813
|
+
if (publicDir === void 0) {
|
|
814
|
+
return [defaultConfig];
|
|
815
|
+
}
|
|
816
|
+
if (Array.isArray(publicDir)) {
|
|
817
|
+
return publicDir.map((options) => ({
|
|
818
|
+
...defaultConfig,
|
|
819
|
+
...options
|
|
820
|
+
}));
|
|
821
|
+
}
|
|
822
|
+
return [
|
|
823
|
+
{
|
|
824
|
+
...defaultConfig,
|
|
825
|
+
...publicDir
|
|
826
|
+
}
|
|
827
|
+
];
|
|
828
|
+
};
|
|
801
829
|
}
|
|
802
830
|
});
|
|
803
831
|
|
|
@@ -828,6 +856,7 @@ function loadEnv({
|
|
|
828
856
|
for (const key of Object.keys(process.env)) {
|
|
829
857
|
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
|
830
858
|
const val = process.env[key];
|
|
859
|
+
publicVars[`import.meta.env.${key}`] = JSON.stringify(val);
|
|
831
860
|
publicVars[`process.env.${key}`] = JSON.stringify(val);
|
|
832
861
|
}
|
|
833
862
|
}
|
|
@@ -1003,7 +1032,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
1003
1032
|
return {
|
|
1004
1033
|
entry: getEntryObject(config, "web"),
|
|
1005
1034
|
targets: config.output?.targets || [],
|
|
1006
|
-
version: "0.7.
|
|
1035
|
+
version: "0.7.7",
|
|
1007
1036
|
rootPath,
|
|
1008
1037
|
distPath,
|
|
1009
1038
|
cachePath,
|
|
@@ -2037,6 +2066,7 @@ var init_getDevMiddlewares = __esm({
|
|
|
2037
2066
|
import_node_path10 = require("path");
|
|
2038
2067
|
import_node_url2 = __toESM(require("url"));
|
|
2039
2068
|
import_shared19 = require("@rsbuild/shared");
|
|
2069
|
+
init_config();
|
|
2040
2070
|
init_middlewares();
|
|
2041
2071
|
applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
|
|
2042
2072
|
const setupMiddlewares = dev.setupMiddlewares || [];
|
|
@@ -2114,11 +2144,12 @@ var init_getDevMiddlewares = __esm({
|
|
|
2114
2144
|
}
|
|
2115
2145
|
});
|
|
2116
2146
|
}
|
|
2117
|
-
|
|
2147
|
+
const publicDirs = normalizePublicDirs(server?.publicDir);
|
|
2148
|
+
for (const publicDir of publicDirs) {
|
|
2118
2149
|
const { default: sirv } = await import("../compiled/sirv/index.js");
|
|
2119
|
-
const { name } =
|
|
2120
|
-
const
|
|
2121
|
-
const assetMiddleware = sirv(
|
|
2150
|
+
const { name } = publicDir;
|
|
2151
|
+
const normalizedPath = (0, import_node_path10.isAbsolute)(name) ? name : (0, import_node_path10.join)(pwd, name);
|
|
2152
|
+
const assetMiddleware = sirv(normalizedPath, {
|
|
2122
2153
|
etag: true,
|
|
2123
2154
|
dev: true
|
|
2124
2155
|
});
|
|
@@ -2503,11 +2534,15 @@ async function watchDevFiles(devConfig, compileMiddlewareAPI) {
|
|
|
2503
2534
|
return startWatchFiles(watchOptions, compileMiddlewareAPI);
|
|
2504
2535
|
}
|
|
2505
2536
|
function watchServerFiles(serverConfig, compileMiddlewareAPI) {
|
|
2506
|
-
const
|
|
2507
|
-
if (!
|
|
2537
|
+
const publicDirs = normalizePublicDirs(serverConfig.publicDir);
|
|
2538
|
+
if (!publicDirs.length) {
|
|
2539
|
+
return;
|
|
2540
|
+
}
|
|
2541
|
+
const watchPaths = publicDirs.filter((item) => item.watch).map((item) => item.name);
|
|
2542
|
+
if (!watchPaths.length) {
|
|
2508
2543
|
return;
|
|
2509
2544
|
}
|
|
2510
|
-
const watchOptions = prepareWatchOptions(
|
|
2545
|
+
const watchOptions = prepareWatchOptions(watchPaths);
|
|
2511
2546
|
return startWatchFiles(watchOptions, compileMiddlewareAPI);
|
|
2512
2547
|
}
|
|
2513
2548
|
function prepareWatchOptions(paths, options = {}) {
|
|
@@ -2527,6 +2562,7 @@ async function startWatchFiles({ paths, options }, compileMiddlewareAPI) {
|
|
|
2527
2562
|
var init_watchFiles = __esm({
|
|
2528
2563
|
"src/server/watchFiles.ts"() {
|
|
2529
2564
|
"use strict";
|
|
2565
|
+
init_config();
|
|
2530
2566
|
}
|
|
2531
2567
|
});
|
|
2532
2568
|
|
|
@@ -3291,12 +3327,12 @@ var init_basic = __esm({
|
|
|
3291
3327
|
name: "rsbuild:basic",
|
|
3292
3328
|
setup(api) {
|
|
3293
3329
|
api.modifyBundlerChain(
|
|
3294
|
-
(chain, { env, isProd:
|
|
3330
|
+
(chain, { env, isProd: isProd6, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
|
|
3295
3331
|
const config = api.getNormalizedConfig();
|
|
3296
3332
|
chain.name(import_shared25.TARGET_ID_MAP[target]);
|
|
3297
3333
|
chain.devtool((0, import_shared25.getJsSourceMap)(config));
|
|
3298
3334
|
chain.context(api.context.rootPath);
|
|
3299
|
-
chain.mode(
|
|
3335
|
+
chain.mode(isProd6 ? "production" : "development");
|
|
3300
3336
|
chain.merge({
|
|
3301
3337
|
infrastructureLogging: {
|
|
3302
3338
|
// Using `error` level to avoid `cache.PackFileCacheStrategy` logs
|
|
@@ -3309,9 +3345,9 @@ var init_basic = __esm({
|
|
|
3309
3345
|
exportsPresence: "error"
|
|
3310
3346
|
}
|
|
3311
3347
|
});
|
|
3312
|
-
const isMinimize =
|
|
3348
|
+
const isMinimize = isProd6 && config.output.minify !== false;
|
|
3313
3349
|
chain.optimization.minimize(isMinimize);
|
|
3314
|
-
const usingHMR = (0, import_shared25.isUsingHMR)(config, { target, isProd:
|
|
3350
|
+
const usingHMR = (0, import_shared25.isUsingHMR)(config, { target, isProd: isProd6 });
|
|
3315
3351
|
if (usingHMR) {
|
|
3316
3352
|
chain.plugin(CHAIN_ID3.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
|
|
3317
3353
|
}
|
|
@@ -3493,7 +3529,7 @@ async function applyCSSRule({
|
|
|
3493
3529
|
rule,
|
|
3494
3530
|
config,
|
|
3495
3531
|
context,
|
|
3496
|
-
utils: { target, isProd:
|
|
3532
|
+
utils: { target, isProd: isProd6, CHAIN_ID: CHAIN_ID3 },
|
|
3497
3533
|
importLoaders = 1
|
|
3498
3534
|
}) {
|
|
3499
3535
|
const browserslist = await (0, import_shared28.getBrowserslistWithDefault)(
|
|
@@ -3502,7 +3538,7 @@ async function applyCSSRule({
|
|
|
3502
3538
|
target
|
|
3503
3539
|
);
|
|
3504
3540
|
const enableExtractCSS = isUseCssExtract(config, target);
|
|
3505
|
-
const localIdentName = getCSSModulesLocalIdentName(config,
|
|
3541
|
+
const localIdentName = getCSSModulesLocalIdentName(config, isProd6);
|
|
3506
3542
|
const cssLoaderOptions = getCSSLoaderOptions({
|
|
3507
3543
|
config,
|
|
3508
3544
|
importLoaders,
|
|
@@ -3545,8 +3581,8 @@ var init_css = __esm({
|
|
|
3545
3581
|
init_pluginHelper();
|
|
3546
3582
|
enableNativeCss = (config) => !config.output.injectStyles;
|
|
3547
3583
|
isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
|
|
3548
|
-
getCSSModulesLocalIdentName = (config,
|
|
3549
|
-
(
|
|
3584
|
+
getCSSModulesLocalIdentName = (config, isProd6) => config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
|
|
3585
|
+
(isProd6 ? "[local]-[hash:base64:6]" : "[path][name]__[local]-[hash:base64:6]");
|
|
3550
3586
|
normalizeCssLoaderOptions = (options, exportOnlyLocals) => {
|
|
3551
3587
|
if (options.modules && exportOnlyLocals) {
|
|
3552
3588
|
let { modules } = options;
|
|
@@ -3693,13 +3729,13 @@ __export(output_exports, {
|
|
|
3693
3729
|
pluginOutput: () => pluginOutput
|
|
3694
3730
|
});
|
|
3695
3731
|
function getPublicPath({
|
|
3696
|
-
isProd:
|
|
3732
|
+
isProd: isProd6,
|
|
3697
3733
|
config,
|
|
3698
3734
|
context
|
|
3699
3735
|
}) {
|
|
3700
3736
|
const { dev, output } = config;
|
|
3701
3737
|
let publicPath = import_shared29.DEFAULT_ASSET_PREFIX;
|
|
3702
|
-
if (
|
|
3738
|
+
if (isProd6) {
|
|
3703
3739
|
if (typeof output.assetPrefix === "string") {
|
|
3704
3740
|
publicPath = output.assetPrefix;
|
|
3705
3741
|
}
|
|
@@ -3733,16 +3769,16 @@ var init_output = __esm({
|
|
|
3733
3769
|
name: "rsbuild:output",
|
|
3734
3770
|
setup(api) {
|
|
3735
3771
|
api.modifyBundlerChain(
|
|
3736
|
-
async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd:
|
|
3772
|
+
async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd: isProd6, isServer, isServiceWorker }) => {
|
|
3737
3773
|
const config = api.getNormalizedConfig();
|
|
3738
3774
|
const publicPath = getPublicPath({
|
|
3739
3775
|
config,
|
|
3740
|
-
isProd:
|
|
3776
|
+
isProd: isProd6,
|
|
3741
3777
|
context: api.context
|
|
3742
3778
|
});
|
|
3743
3779
|
const jsPath = (0, import_shared29.getDistPath)(config, "js");
|
|
3744
3780
|
const jsAsyncPath = (0, import_shared29.getDistPath)(config, "jsAsync");
|
|
3745
|
-
const jsFilename = (0, import_shared29.getFilename)(config, "js",
|
|
3781
|
+
const jsFilename = (0, import_shared29.getFilename)(config, "js", isProd6);
|
|
3746
3782
|
const isJsFilenameFn = typeof jsFilename === "function";
|
|
3747
3783
|
chain.output.path(api.context.distPath).filename(
|
|
3748
3784
|
isJsFilenameFn ? (...args) => {
|
|
@@ -3775,7 +3811,7 @@ var init_output = __esm({
|
|
|
3775
3811
|
if (isUseCssExtract(config, target)) {
|
|
3776
3812
|
const extractPluginOptions = config.tools.cssExtract.pluginOptions;
|
|
3777
3813
|
const cssPath = (0, import_shared29.getDistPath)(config, "css");
|
|
3778
|
-
const cssFilename = (0, import_shared29.getFilename)(config, "css",
|
|
3814
|
+
const cssFilename = (0, import_shared29.getFilename)(config, "css", isProd6);
|
|
3779
3815
|
const cssAsyncPath = (0, import_shared29.getDistPath)(config, "cssAsync");
|
|
3780
3816
|
chain.plugin(CHAIN_ID3.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
|
|
3781
3817
|
{
|
|
@@ -4151,12 +4187,12 @@ var init_asset = __esm({
|
|
|
4151
4187
|
pluginAsset = () => ({
|
|
4152
4188
|
name: "rsbuild:asset",
|
|
4153
4189
|
setup(api) {
|
|
4154
|
-
api.modifyBundlerChain((chain, { isProd:
|
|
4190
|
+
api.modifyBundlerChain((chain, { isProd: isProd6, target }) => {
|
|
4155
4191
|
const config = api.getNormalizedConfig();
|
|
4156
4192
|
const createAssetRule = (assetType, exts, emit2) => {
|
|
4157
4193
|
const regExp = getRegExpForExts(exts);
|
|
4158
4194
|
const distDir = (0, import_shared34.getDistPath)(config, assetType);
|
|
4159
|
-
const filename = (0, import_shared34.getFilename)(config, assetType,
|
|
4195
|
+
const filename = (0, import_shared34.getFilename)(config, assetType, isProd6);
|
|
4160
4196
|
const { dataUriLimit } = config.output;
|
|
4161
4197
|
const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit[assetType];
|
|
4162
4198
|
const rule = chain.module.rule(assetType).test(regExp);
|
|
@@ -4234,9 +4270,9 @@ var init_minimize = __esm({
|
|
|
4234
4270
|
}
|
|
4235
4271
|
return options;
|
|
4236
4272
|
};
|
|
4237
|
-
parseMinifyOptions = (config,
|
|
4273
|
+
parseMinifyOptions = (config, isProd6 = true) => {
|
|
4238
4274
|
const minify = config.output.minify;
|
|
4239
|
-
if (minify === false || !
|
|
4275
|
+
if (minify === false || !isProd6) {
|
|
4240
4276
|
return {
|
|
4241
4277
|
minifyJs: false,
|
|
4242
4278
|
minifyCss: false,
|
|
@@ -4268,9 +4304,9 @@ var init_minimize = __esm({
|
|
|
4268
4304
|
if (api.context.bundlerType === "webpack") {
|
|
4269
4305
|
return;
|
|
4270
4306
|
}
|
|
4271
|
-
api.modifyBundlerChain(async (chain, { isProd:
|
|
4307
|
+
api.modifyBundlerChain(async (chain, { isProd: isProd6 }) => {
|
|
4272
4308
|
const config = api.getNormalizedConfig();
|
|
4273
|
-
const isMinimize =
|
|
4309
|
+
const isMinimize = isProd6 && config.output.minify !== false;
|
|
4274
4310
|
if (!isMinimize) {
|
|
4275
4311
|
return;
|
|
4276
4312
|
}
|
|
@@ -4609,8 +4645,8 @@ function getTerserMinifyOptions(config) {
|
|
|
4609
4645
|
const finalOptions = applyRemoveConsole(options, config);
|
|
4610
4646
|
return finalOptions;
|
|
4611
4647
|
}
|
|
4612
|
-
async function getHtmlMinifyOptions(
|
|
4613
|
-
if (!
|
|
4648
|
+
async function getHtmlMinifyOptions(isProd6, config) {
|
|
4649
|
+
if (!isProd6 || !config.output.minify || !parseMinifyOptions(config).minifyHtml) {
|
|
4614
4650
|
return false;
|
|
4615
4651
|
}
|
|
4616
4652
|
const minifyJS = getTerserMinifyOptions(config);
|
|
@@ -4761,12 +4797,12 @@ var init_html = __esm({
|
|
|
4761
4797
|
name: "rsbuild:html",
|
|
4762
4798
|
setup(api) {
|
|
4763
4799
|
api.modifyBundlerChain(
|
|
4764
|
-
async (chain, { HtmlPlugin, isProd:
|
|
4800
|
+
async (chain, { HtmlPlugin, isProd: isProd6, CHAIN_ID: CHAIN_ID3, target }) => {
|
|
4765
4801
|
const config = api.getNormalizedConfig();
|
|
4766
4802
|
if ((0, import_shared38.isHtmlDisabled)(config, target)) {
|
|
4767
4803
|
return;
|
|
4768
4804
|
}
|
|
4769
|
-
const minify = await getHtmlMinifyOptions(
|
|
4805
|
+
const minify = await getHtmlMinifyOptions(isProd6, config);
|
|
4770
4806
|
const assetPrefix = getPublicPathFromChain(chain, false);
|
|
4771
4807
|
const entries = chain.entryPoints.entries() || {};
|
|
4772
4808
|
const entryNames = Object.keys(entries);
|
|
@@ -6283,28 +6319,30 @@ var init_server = __esm({
|
|
|
6283
6319
|
"use strict";
|
|
6284
6320
|
import_node_path26 = require("path");
|
|
6285
6321
|
import_shared51 = require("@rsbuild/shared");
|
|
6322
|
+
init_config();
|
|
6286
6323
|
pluginServer = () => ({
|
|
6287
6324
|
name: "rsbuild:server",
|
|
6288
6325
|
setup(api) {
|
|
6289
6326
|
api.onBeforeBuild(async () => {
|
|
6290
6327
|
const config = api.getNormalizedConfig();
|
|
6291
|
-
|
|
6292
|
-
|
|
6328
|
+
const publicDirs = normalizePublicDirs(config.server.publicDir);
|
|
6329
|
+
for (const publicDir of publicDirs) {
|
|
6330
|
+
const { name, copyOnBuild } = publicDir;
|
|
6293
6331
|
if (!copyOnBuild || !name) {
|
|
6294
|
-
|
|
6332
|
+
continue;
|
|
6295
6333
|
}
|
|
6296
|
-
const
|
|
6297
|
-
if (!import_shared51.fse.existsSync(
|
|
6298
|
-
|
|
6334
|
+
const normalizedPath = (0, import_node_path26.isAbsolute)(name) ? name : (0, import_node_path26.join)(api.context.rootPath, name);
|
|
6335
|
+
if (!import_shared51.fse.existsSync(normalizedPath)) {
|
|
6336
|
+
continue;
|
|
6299
6337
|
}
|
|
6300
6338
|
try {
|
|
6301
|
-
await import_shared51.fse.copy(
|
|
6339
|
+
await import_shared51.fse.copy(normalizedPath, api.context.distPath, {
|
|
6302
6340
|
// dereference symlinks
|
|
6303
6341
|
dereference: true
|
|
6304
6342
|
});
|
|
6305
6343
|
} catch (err) {
|
|
6306
6344
|
if (err instanceof Error) {
|
|
6307
|
-
err.message = `Copy public dir (${
|
|
6345
|
+
err.message = `Copy public dir (${normalizedPath}) to dist failed:
|
|
6308
6346
|
${err.message}`;
|
|
6309
6347
|
}
|
|
6310
6348
|
throw err;
|
|
@@ -6640,8 +6678,8 @@ var init_lazyCompilation = __esm({
|
|
|
6640
6678
|
pluginLazyCompilation = () => ({
|
|
6641
6679
|
name: "rsbuild:lazy-compilation",
|
|
6642
6680
|
setup(api) {
|
|
6643
|
-
api.modifyBundlerChain((chain, { isProd:
|
|
6644
|
-
if (
|
|
6681
|
+
api.modifyBundlerChain((chain, { isProd: isProd6, target }) => {
|
|
6682
|
+
if (isProd6 || target !== "web") {
|
|
6645
6683
|
return;
|
|
6646
6684
|
}
|
|
6647
6685
|
const config = api.getNormalizedConfig();
|
|
@@ -7224,7 +7262,7 @@ var applyServerOptions = (command) => {
|
|
|
7224
7262
|
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
7225
7263
|
};
|
|
7226
7264
|
function runCli() {
|
|
7227
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7265
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.7");
|
|
7228
7266
|
const devCommand = import_commander.program.command("dev");
|
|
7229
7267
|
const buildCommand = import_commander.program.command("build");
|
|
7230
7268
|
const previewCommand = import_commander.program.command("preview");
|
|
@@ -7314,7 +7352,7 @@ function prepareCli() {
|
|
|
7314
7352
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7315
7353
|
console.log();
|
|
7316
7354
|
}
|
|
7317
|
-
import_shared61.logger.greet(` ${`Rsbuild v${"0.7.
|
|
7355
|
+
import_shared61.logger.greet(` ${`Rsbuild v${"0.7.7"}`}
|
|
7318
7356
|
`);
|
|
7319
7357
|
}
|
|
7320
7358
|
|
|
@@ -7341,7 +7379,7 @@ init_config();
|
|
|
7341
7379
|
var import_shared62 = require("@rsbuild/shared");
|
|
7342
7380
|
init_mergeConfig();
|
|
7343
7381
|
init_constants();
|
|
7344
|
-
var version = "0.7.
|
|
7382
|
+
var version = "0.7.7";
|
|
7345
7383
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7346
7384
|
0 && (module.exports = {
|
|
7347
7385
|
PLUGIN_CSS_NAME,
|