From 809914a4cb054228ea91d431a37510434aca1ca1 Mon Sep 17 00:00:00 2001 From: zeroberry <98147817+zeroberry@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:05:52 +0900 Subject: [PATCH] fix: set compilerOptions.css to 'injected' when emitCss is false --- index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 6e32b7e..805efd2 100644 --- a/index.js +++ b/index.js @@ -45,17 +45,17 @@ module.exports = function (options = {}) { const cache_emit = new Map(); const { onwarn, emitCss = true } = rest; - if (emitCss) { - const cssOptionValue = majorVersion > 3 ? 'external' : false; - if (compilerOptions.css) { - console.warn( - `${PREFIX} Forcing \`"compilerOptions.css": ${ - typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue - }\` because "emitCss" was truthy.` - ); - } - compilerOptions.css = cssOptionValue; + // Override `compilerOptions.css` based on `emitCss` + const cssOptionValue = + majorVersion > 3 ? (emitCss ? 'external' : 'injected') : emitCss ? false : true; + if (compilerOptions.css !== undefined && compilerOptions.css !== cssOptionValue) { + console.warn( + `${PREFIX} Forcing "compilerOptions.css": ${ + typeof cssOptionValue === 'string' ? `"${cssOptionValue}"` : cssOptionValue + } because "emitCss" was ${emitCss ? 'truthy' : 'falsy'}.` + ); } + compilerOptions.css = cssOptionValue; return { name: 'svelte',