From bf92d4a6778509c038dd09f8358fdc07691d76ee Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Sun, 1 Dec 2024 11:06:41 +0100 Subject: [PATCH] wip --- test/playground/vite.config.ts | 3 ++- vike/node/plugin/plugins/buildConfig.ts | 2 ++ .../plugin/plugins/buildConfig/fixServerAssets.ts | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/playground/vite.config.ts b/test/playground/vite.config.ts index b0135cb2705..ead5e70afd8 100644 --- a/test/playground/vite.config.ts +++ b/test/playground/vite.config.ts @@ -5,7 +5,8 @@ export default { // TEST: funky build output directory build: { outDir: `${__dirname}/../../test/playground/dist/nested`, - assetsDir: '/nested-dir/assets' + assetsDir: '/nested-dir/assets', + cssCodeSplit: false }, plugins: [ react(), diff --git a/vike/node/plugin/plugins/buildConfig.ts b/vike/node/plugin/plugins/buildConfig.ts index 1d62a68b3f4..fc621805458 100644 --- a/vike/node/plugin/plugins/buildConfig.ts +++ b/vike/node/plugin/plugins/buildConfig.ts @@ -31,6 +31,7 @@ import fs from 'fs/promises' import path from 'path' import { fixServerAssets, + fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget, fixServerAssets_assertCssTarget_populate, fixServerAssets_isEnabled @@ -73,6 +74,7 @@ function buildConfig(): Plugin[] { // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934 config.build.cssMinify = 'esbuild' fixServerAssets_assertCssTarget_populate(config) + fixServerAssets_assertCssCodeSplit(config) } } } diff --git a/vike/node/plugin/plugins/buildConfig/fixServerAssets.ts b/vike/node/plugin/plugins/buildConfig/fixServerAssets.ts index 875c59cbdc9..555d82f16fc 100644 --- a/vike/node/plugin/plugins/buildConfig/fixServerAssets.ts +++ b/vike/node/plugin/plugins/buildConfig/fixServerAssets.ts @@ -1,5 +1,6 @@ export { fixServerAssets } export { fixServerAssets_isEnabled } +export { fixServerAssets_assertCssCodeSplit } export { fixServerAssets_assertCssTarget } export { fixServerAssets_assertCssTarget_populate } @@ -191,6 +192,17 @@ function getHash(src: string) { return hash } +// https://github.com/vikejs/vike/issues/1993 +function fixServerAssets_assertCssCodeSplit(config: ResolvedConfig) { + assertWarning( + config.build.cssCodeSplit, + `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan( + 'false' + )} (https://github.com/vikejs/vike/issues/1993)`, + { onlyOnce: true } + ) +} + // https://github.com/vikejs/vike/issues/1815 type Target = undefined | false | string | string[] type TargetConfig = { global: Exclude; css: Target; isServerSide: boolean }