diff --git a/packages/core/src/plugins/appIcon.ts b/packages/core/src/plugins/appIcon.ts index 8c01e2849d..a24acfb1c4 100644 --- a/packages/core/src/plugins/appIcon.ts +++ b/packages/core/src/plugins/appIcon.ts @@ -22,7 +22,7 @@ type IconExtra = { ); export const pluginAppIcon = (): RsbuildPlugin => ({ - name: 'rsbuild:app-icon', + name: 'rsbuild:appIcon', setup(api) { const htmlTagsMap = new Map(); @@ -103,7 +103,7 @@ export const pluginAppIcon = (): RsbuildPlugin => ({ if (icon.target === 'web-app-manifest' && !appIcon.name) { addCompilationError( compilation, - `${color.dim('[rsbuild:app-icon]')} ${color.yellow( + `${color.dim('[rsbuild:appIcon]')} ${color.yellow( '"appIcon.name"', )} is required when ${color.yellow('"target"')} is ${color.yellow( '"web-app-manifest"', @@ -116,7 +116,7 @@ export const pluginAppIcon = (): RsbuildPlugin => ({ if (!compilation.inputFileSystem) { addCompilationError( compilation, - `${color.dim('[rsbuild:app-icon]')} Failed to read the icon file as ${color.yellow( + `${color.dim('[rsbuild:appIcon]')} Failed to read the icon file as ${color.yellow( '"compilation.inputFileSystem"', )} is not available.`, ); @@ -128,7 +128,7 @@ export const pluginAppIcon = (): RsbuildPlugin => ({ ) { addCompilationError( compilation, - `${color.dim('[rsbuild:app-icon]')} Failed to find the icon file at ${color.yellow( + `${color.dim('[rsbuild:appIcon]')} Failed to find the icon file at ${color.yellow( icon.absolutePath, )}.`, ); diff --git a/packages/core/src/plugins/cleanOutput.ts b/packages/core/src/plugins/cleanOutput.ts index 15e6ffdaeb..6cf452730f 100644 --- a/packages/core/src/plugins/cleanOutput.ts +++ b/packages/core/src/plugins/cleanOutput.ts @@ -133,6 +133,17 @@ export const pluginCleanOutput = (): RsbuildPlugin => ({ // Use `for...of` to handle nested directories correctly for (const pathInfo of pathInfos) { + // Users may mistakenly set `output.distPath.root` to '/' + if (pathInfo.path === '/') { + const prefix = color.dim('[rsbuild:cleanOutput]'); + throw new Error( + `${prefix} Refusing to clean output at ${color.cyan( + `"${pathInfo.path}"`, + )}. Update ${color.yellow( + '`output.distPath.root`', + )} or set ${color.yellow('`output.cleanDistPath`')} to false.`, + ); + } await emptyDir(pathInfo.path, pathInfo.keep); } }; diff --git a/packages/core/src/plugins/nodeAddons.ts b/packages/core/src/plugins/nodeAddons.ts index ea8eaa5b7f..840c05dcf6 100644 --- a/packages/core/src/plugins/nodeAddons.ts +++ b/packages/core/src/plugins/nodeAddons.ts @@ -18,7 +18,7 @@ export const pluginNodeAddons = (): RsbuildPlugin => ({ if (filename === null) { throw new Error( - `${color.dim('[rsbuild:node-addons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`, + `${color.dim('[rsbuild:nodeAddons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`, ); }