This commit is contained in:
10
src/index.ts
10
src/index.ts
@@ -1,4 +1,4 @@
|
||||
import { extname } from "node:path";
|
||||
import path, { extname } from "node:path";
|
||||
|
||||
import type {
|
||||
Plugin,
|
||||
@@ -48,6 +48,7 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
||||
const {
|
||||
publicPath,
|
||||
transform,
|
||||
rewriteUrl,
|
||||
load,
|
||||
htmlFileNames,
|
||||
resolve,
|
||||
@@ -353,7 +354,12 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
||||
htmlContents = htmlContents.replace(htmlImport.placeholder, importResult.code);
|
||||
}else if(htmlImport.type === 'entryChunk'){
|
||||
const relPath = posix.relative(dirname(chunk.fileName), importResult.fileName);
|
||||
htmlContents = htmlContents.replace(htmlImport.placeholder, relPath);
|
||||
const rootPath = path.posix.join(dirname(chunk.fileName), relPath);
|
||||
const rewritten = rewriteUrl? await Promise.resolve(rewriteUrl(relPath, {
|
||||
from: chunk.fileName,
|
||||
rootPath,
|
||||
})): relPath;
|
||||
htmlContents = htmlContents.replace(htmlImport.placeholder, rewritten);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user