diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index f059fa407a..eab0a6f4ce 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -3,7 +3,7 @@ import { join } from 'node:path'; // Paths // loaders will be emitted to the same folder of the main bundle export const ROOT_DIST_DIR = 'dist'; -export const HTML_DIST_DIR = '/'; +export const HTML_DIST_DIR = ''; export const JS_DIST_DIR = 'static/js'; export const CSS_DIST_DIR = 'static/css'; export const SVG_DIST_DIR = 'static/svg'; diff --git a/packages/core/src/initPlugins.ts b/packages/core/src/initPlugins.ts index 42494d161b..a8ded4eeb9 100644 --- a/packages/core/src/initPlugins.ts +++ b/packages/core/src/initPlugins.ts @@ -4,6 +4,7 @@ import { LOADER_PATH } from './constants'; import { createPublicContext } from './createContext'; import { removeLeadingSlash } from './helpers'; import type { TransformLoaderOptions } from './loader/transformLoader'; +import { logger } from './logger'; import { isPluginMatchEnvironment } from './pluginManager'; import type { GetRsbuildConfig, @@ -34,7 +35,15 @@ export function getHTMLPathByEntry( filename = `${entryName}/index.html`; } - return removeLeadingSlash(posix.join(config.output.distPath.html, filename)); + const prefix = config.output.distPath.html; + + if (prefix.startsWith('/')) { + logger.warn( + `Absolute path is not recommended at \`output.distPath.html\`: "${prefix}", please use relative path instead.`, + ); + } + + return removeLeadingSlash(posix.join(prefix, filename)); } const mapProcessAssetsStage = (