Skip to content

Commit dba1221

Browse files
committed
fix: dont server render url imported css
1 parent 6212171 commit dba1221

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ export async function findStylesInModuleGraph(vite: ViteDevServer, id: string, s
151151
for (const dep of dependencies) {
152152
if (isCssFile(dep.url)) {
153153
let depURL = dep.url;
154+
if (depURL.endsWith("?url")) {
155+
continue;
156+
}
157+
154158
if (!isCssUrlWithoutSideEffects(depURL)) {
155159
depURL = injectQuery(dep.url, "inline");
156160
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { clientViteManifest } from "solid-start:client-vite-manifest"
21
import { join } from "pathe";
3-
import type { Asset } from "../renderAsset.jsx";
2+
import { clientViteManifest } from "solid-start:client-vite-manifest";
3+
import { Manifest } from "vite";
44
import { CLIENT_BASE_PATH } from "../../constants.js";
5+
import type { Asset } from "../renderAsset.jsx";
56

67
// Only reads from client manifest atm, might need server support for islands
78
export function getSsrProdManifest() {
@@ -57,7 +58,7 @@ function createHtmlTagsForAssets(assets: string[]) {
5758
}));
5859
}
5960

60-
function findAssetsInViteManifest(manifest: any, id: string, assetMap = new Map(), stack: string[] = []) {
61+
function findAssetsInViteManifest(manifest: Manifest, id: string, assetMap = new Map(), stack: string[] = []) {
6162
if (stack.includes(id)) {
6263
return [];
6364
}
@@ -72,13 +73,14 @@ function findAssetsInViteManifest(manifest: any, id: string, assetMap = new Map(
7273
}
7374

7475
const assets = [
75-
...(chunk.assets?.filter(Boolean) || []),
76+
// TODO: Needs a better way to detect ?url
77+
...(chunk.assets?.filter(a => !a.endsWith('.css')) || []),
7678
...(chunk.css?.filter(Boolean) || [])
7779
];
7880
if (chunk.imports) {
7981
stack.push(id);
8082
for (let i = 0, l = chunk.imports.length; i < l; i++) {
81-
assets.push(...findAssetsInViteManifest(manifest, chunk.imports[i], assetMap, stack));
83+
assets.push(...findAssetsInViteManifest(manifest, chunk.imports[i]!, assetMap, stack));
8284
}
8385
stack.pop();
8486
}

0 commit comments

Comments
 (0)