fix: Page switching display is abnormal

This commit is contained in:
vben
2024-06-23 19:55:55 +08:00
parent 16ed5a05ba
commit 89586ef2c4
5 changed files with 10 additions and 32 deletions

View File

@@ -1,6 +1,5 @@
import type {
NormalizedOutputOptions,
OutputAsset,
OutputBundle,
OutputChunk,
} from 'rollup';
@@ -45,25 +44,14 @@ async function viteLicensePlugin(
`.trim();
for (const [, fileContent] of Object.entries(bundle)) {
if (
fileContent.type === 'asset' ||
(fileContent.type === 'chunk' && fileContent.isEntry)
) {
if (fileContent.type === 'chunk' && fileContent.isEntry) {
const chunkContent = fileContent as OutputChunk;
const assetContent = fileContent as OutputAsset;
// 插入版权信息
const content =
typeof assetContent.source === 'string'
? assetContent.source
: chunkContent.code;
const content = chunkContent.code;
const updatedContent = `${copyrightText}${EOL}${content}`;
// 更新bundle
if (assetContent.source === undefined) {
(fileContent as OutputChunk).code = updatedContent;
} else {
(fileContent as OutputAsset).source = updatedContent;
}
(fileContent as OutputChunk).code = updatedContent;
}
}
},