Skip to content

Commit

Permalink
[#100] Wrong globalCssToInject - remove old plugin-legacy support sin…
Browse files Browse the repository at this point in the history
…ce isn't required anymore (#104)
  • Loading branch information
marco-prontera committed Jul 6, 2023
1 parent 827c355 commit 13c28dc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ export async function relativeCssInjection(
}
}

// Globally so we can add it to legacy and non-legacy bundle.
let globalCssToInject = '';
export async function globalCssInjection(
bundle: OutputBundle,
cssAssets: string[],
Expand All @@ -243,18 +241,15 @@ export async function globalCssInjection(
process.env.VITE_CSS_INJECTED_BY_JS_DEBUG &&
debugLog(`[vite-plugin-css-injected-by-js] Global CSS Assets: [${cssAssets.join(',')}]`);
const allCssCode = concatCssAndDeleteFromBundle(bundle, cssAssets);
if (allCssCode.length > 0) {
globalCssToInject = allCssCode;
}
const globalCssInjectionCode = globalCssToInject.length > 0 ? (await buildCssCode(globalCssToInject))?.code : '';
const cssInjectionCode = allCssCode.length > 0 ? (await buildCssCode(allCssCode))?.code : '';

for (const jsTargetKey of jsTargetBundleKeys) {
const jsAsset = bundle[jsTargetKey] as OutputChunk;
process.env.VITE_CSS_INJECTED_BY_JS_DEBUG &&
debugLog(`[vite-plugin-css-injected-by-js] Global CSS inject: ${jsAsset.fileName}`);
jsAsset.code = buildOutputChunkWithCssInjectionCode(
jsAsset.code,
globalCssInjectionCode ?? '',
cssInjectionCode ?? '',
topExecutionPriorityFlag
);
}
Expand Down

0 comments on commit 13c28dc

Please sign in to comment.