Skip to content

Commit

Permalink
fix: override of 'build.cssCodeSplit' will not take effect if `config…
Browse files Browse the repository at this point in the history
….build.cssCodeSplit` is `undefined`
  • Loading branch information
voldikss authored Sep 12, 2024
1 parent 6c30640 commit 35188fe
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,12 @@ export default function cssInjectedByJsPlugin({
enforce: 'post',
name: 'vite-plugin-css-injected-by-js',
config(config, env) {
if (env.command === 'build') {
if (!config.build) {
config.build = {};
}

if (relativeCSSInjection == true) {
if (config.build.cssCodeSplit == false) {
config.build.cssCodeSplit = true;
warnLog(
`[vite-plugin-css-injected-by-js] Override of 'build.cssCodeSplit' option to true, it must be true when 'relativeCSSInjection' is enabled.`
);
}
if (env.command === 'serve') return
if (!relativeCSSInjection) return
warnLog(`[vite-plugin-css-injected-by-js] Override of 'build.cssCodeSplit' option to true, it must be true when 'relativeCSSInjection' is enabled.`);
return {
build: {
cssCodeSplit: true
}
}
},
Expand Down

0 comments on commit 35188fe

Please sign in to comment.