@@ -877,20 +877,23 @@ export default defineConfig({
877877
878878 build : {
879879 // Never inline assets as `data:` URLs. Output's `StripCSSImport`
880- // transform rewrites `import "./foo.css"` to
881- // `_LOAD_CSS_WORKER(new URL("./foo.css", import.meta.url).pathname)`.
882- // Vite recognises the `new URL(literal, import.meta.url)` pattern
883- // and, by default, inlines small assets as
884- // `data:text/css;base64,...` URLs. The runtime call
885- // `new URL("data:text/css;...", base).pathname` then strips the
886- // `data:` scheme and yields a bare `text/css;base64,...` string,
887- // which `_LOAD_CSS_WORKER` tries to fetch as a path and the
888- // browser 404s with `non CSS MIME types are not allowed in
889- // strict mode`. Setting `assetsInlineLimit: 0` forces every
890- // referenced CSS asset to emit as a hashed file under `_astro/`
891- // where the runtime worker can fetch it the same way it does
892- // for larger CSS chunks.
880+ // transform (now skipped for the bundled tree, see
881+ // `Output/Source/ApplyPipeline.ts`) used to rewrite
882+ // `import "./foo.css"` into a `_LOAD_CSS_WORKER(new URL(
883+ // "./foo.css", import.meta.url).pathname)` call. Vite would
884+ // recognise the `new URL(literal, import.meta.url)` pattern
885+ // and inline small assets as `data:text/css;base64,...` URLs,
886+ // then the runtime call would strip the `data:` scheme and
887+ // fail. Keeping `assetsInlineLimit: 0` defensively even though
888+ // the transform path is no longer the primary one.
893889 assetsInlineLimit : 0 ,
890+ // Fold every CSS module into one bundled file (per entry).
891+ // Default Vite behaviour code-splits CSS per dynamic import,
892+ // emitting ~75+ individual `_astro/*.css` chunks. With
893+ // `cssCodeSplit: false` Vite concatenates all CSS reachable
894+ // from the bundled workbench entry into a single hashed
895+ // `*.css` file the runtime loads once.
896+ cssCodeSplit : false ,
894897 rollupOptions : {
895898 // Bundled-workbench Rollup inputs. When `Pack`
896899 // is empty this map is empty and Astro's auto-generated page
@@ -939,6 +942,33 @@ export default defineConfig({
939942 output : {
940943 // Preserve dynamic URL imports in VSCode worker files
941944 hoistTransitiveImports : false ,
945+ // Fold every VS Code module reachable from the bundled
946+ // workbench entry into a single chunk. Without this,
947+ // Rollup auto-splits at static-import boundaries and
948+ // emits ~60 separate chunks (the largest is the
949+ // node-named one Rollup elects as "main"). With this,
950+ // one big `workbench-[hash].js` lands and the runtime
951+ // fetches a single JS asset instead of waterfalling
952+ // through dozens. Astro page scripts (NLS,
953+ // TelemetryBridge, Bootstrap, SkyBridge) are left to
954+ // default chunking - they have different lifecycles
955+ // from the workbench and shouldn't share a chunk.
956+ manualChunks : BundledActive
957+ ? ( id : string ) => {
958+ if (
959+ id . includes (
960+ "/Output/Target/Microsoft/VSCode/" ,
961+ ) ||
962+ id . includes (
963+ "\\Output\\Target\\Microsoft\\VSCode\\" ,
964+ ) ||
965+ id . includes ( "/Workbench/Bundled/" )
966+ ) {
967+ return "workbench" ;
968+ }
969+ return null ;
970+ }
971+ : undefined ,
942972 // Route bundled entries to `${BundledOutputDir}/<Variant>/
943973 // workbench-[hash].js`; everything else keeps the existing
944974 // `app.js` / `[name]-[hash].js` shape.
0 commit comments