Skip to content

Commit db35533

Browse files
committed
fix: exclude css with ? import sideeffects from ssr
1 parent d96c5b8 commit db35533

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

packages/start/src/server/collect-styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function findModuleDependencies(
6363
// Vite doesn't expose these so we just copy the list for now
6464
// https://github.com/vitejs/vite/blob/d6bde8b03d433778aaed62afc2be0630c8131908/packages/vite/src/node/constants.ts#L49C23-L50
6565
const cssFileRegExp =
66-
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
66+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)$/;
6767
// https://github.com/vitejs/vite/blob/d6bde8b03d433778aaed62afc2be0630c8131908/packages/vite/src/node/plugins/css.ts#L160
6868
const cssModulesRegExp = new RegExp(`\\.module${cssFileRegExp.source}`);
6969

packages/start/src/server/manifest/prod-ssr-manifest.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { clientViteManifest } from "solid-start:client-vite-manifest";
22
import { join } from "pathe";
3+
import { Manifest } from "vite";
34
import type { Asset } from "../renderAsset.tsx";
45

56
// Only reads from client manifest atm, might need server support for islands
@@ -70,7 +71,7 @@ const entryId = import.meta.env.START_CLIENT_ENTRY.slice(2);
7071
let entryImports: string[] | undefined = undefined;
7172

7273
function findAssetsInViteManifest(
73-
manifest: any,
74+
manifest: Manifest,
7475
id: string,
7576
assetMap = new Map(),
7677
stack: string[] = [],
@@ -99,10 +100,7 @@ function findAssetsInViteManifest(
99100
// Chunks (e.g. routes) that import something from entry, should not render entry css redundantly
100101
const excludeEntryImports = id !== entryId;
101102

102-
const assets = [
103-
...(chunk.assets?.filter(Boolean) || []),
104-
...(chunk.css?.filter(Boolean) || []),
105-
];
103+
const assets = chunk.css?.filter(Boolean) || [];
106104
if (chunk.imports) {
107105
stack.push(id);
108106
for (let i = 0, l = chunk.imports.length; i < l; i++) {

0 commit comments

Comments
 (0)