diff --git a/docs/generated/packages/vite/executors/build.json b/docs/generated/packages/vite/executors/build.json index 2b2a671b0188fc..9fb86319c044b5 100644 --- a/docs/generated/packages/vite/executors/build.json +++ b/docs/generated/packages/vite/executors/build.json @@ -88,6 +88,11 @@ "description": "Force the optimizer to ignore the cache and re-bundle", "type": "boolean" }, + "cssCodeSplit": { + "description": "Enable/disable CSS code splitting. When enabled, CSS imported in async chunks will be inlined into the async chunk itself and inserted when the chunk is loaded.", + "type": "boolean", + "default": true + }, "watch": { "description": "Enable re-building when files change.", "oneOf": [{ "type": "boolean" }, { "type": "object" }], diff --git a/packages/vite/src/executors/build/schema.d.ts b/packages/vite/src/executors/build/schema.d.ts index 7578e3a3e1a1a5..f710f4d5c31443 100644 --- a/packages/vite/src/executors/build/schema.d.ts +++ b/packages/vite/src/executors/build/schema.d.ts @@ -17,4 +17,5 @@ export interface ViteBuildExecutorOptions { target?: string | string[]; generatePackageJson?: boolean; includeDevDependenciesInPackageJson?: boolean; + cssCodeSplit?: boolean; } diff --git a/packages/vite/src/executors/build/schema.json b/packages/vite/src/executors/build/schema.json index a9cb452828b65f..cbde32d56b15de 100644 --- a/packages/vite/src/executors/build/schema.json +++ b/packages/vite/src/executors/build/schema.json @@ -128,6 +128,11 @@ "description": "Force the optimizer to ignore the cache and re-bundle", "type": "boolean" }, + "cssCodeSplit": { + "description": "Enable/disable CSS code splitting. When enabled, CSS imported in async chunks will be inlined into the async chunk itself and inserted when the chunk is loaded.", + "type": "boolean", + "default": true + }, "watch": { "description": "Enable re-building when files change.", "oneOf": [ diff --git a/packages/vite/src/utils/options-utils.ts b/packages/vite/src/utils/options-utils.ts index a6ecf3896dfa47..c0166fb20f356b 100644 --- a/packages/vite/src/utils/options-utils.ts +++ b/packages/vite/src/utils/options-utils.ts @@ -144,7 +144,7 @@ export function getViteBuildOptions( outDir: relative(projectRoot, options.outputPath), emptyOutDir: options.emptyOutDir, reportCompressedSize: true, - cssCodeSplit: true, + cssCodeSplit: options.cssCodeSplit, target: options.target ?? 'esnext', commonjsOptions: { transformMixedEsModules: true,