Skip to content

Commit

Permalink
feat(core): output.distPath.html defaults to '' and warn while acce…
Browse files Browse the repository at this point in the history
…pting absolute path
  • Loading branch information
wjw99830 committed Sep 13, 2024
1 parent ad18cae commit e57246c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
11 changes: 10 additions & 1 deletion packages/core/src/initPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit e57246c

Please sign in to comment.