Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 102c93e

Browse files
committed
Fix build when import css
1 parent 0e60fd1 commit 102c93e

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

server/build.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export async function build(
103103
return importUrl === alephPkgUri + "/server/mod.ts" ||
104104
// since deno deploy doesn't support importMap, we need to resolve the 'react' import
105105
importUrl.startsWith(alephPkgUri + "/framework/react/") ||
106-
importUrl.startsWith(`http://localhost:${Deno.env.get("ALEPH_APP_MODULES_PORT")}/`);
106+
importUrl.startsWith(`http://localhost:${Deno.env.get("ALEPH_APP_MODULES_PORT")}/`) ||
107+
importUrl.endsWith(".css");
107108
};
108109

109110
// build server entry
@@ -135,6 +136,10 @@ export async function build(
135136
const isRemote = util.isLikelyHttpURL(importUrl);
136137
const [path] = util.splitBy(isRemote ? importUrl : util.trimPrefix(importUrl, "file://"), "#");
137138

139+
if (args.kind === "dynamic-import") {
140+
return { path, external: true };
141+
}
142+
138143
if (args.namespace === "http") {
139144
const { href } = new URL(path, args.importer);
140145
if (!forceBundle(href)) {
@@ -160,26 +165,30 @@ export async function build(
160165
}
161166
const res = await cache(url.href);
162167
const contents = await res.text();
163-
let ext = extname(url.pathname).slice(1);
168+
const ext = extname(url.pathname).slice(1);
169+
let loader = ext;
164170
if (ext === "mjs") {
165-
ext = "js";
171+
loader = "js";
166172
} else if (ext === "mts") {
167-
ext = "ts";
168-
} else if (!builtinModuleExts.includes(ext)) {
169-
const ctype = res.headers.get("Content-Type");
170-
if (ctype?.startsWith("application/javascript")) {
171-
ext = "js";
172-
} else if (ctype?.startsWith("application/typescript")) {
173-
ext = "ts";
174-
} else if (ctype?.startsWith("text/jsx")) {
175-
ext = "jsx";
176-
} else if (ctype?.startsWith("text/tsx")) {
177-
ext = "tsx";
178-
}
173+
loader = "ts";
174+
} else if (ext === "pcss" || ext === "postcss") {
175+
loader = "css";
176+
}
177+
const ctype = res.headers.get("Content-Type");
178+
if (ctype?.startsWith("application/javascript")) {
179+
loader = "js";
180+
} else if (ctype?.startsWith("application/typescript")) {
181+
loader = "ts";
182+
} else if (ctype?.startsWith("text/jsx")) {
183+
loader = "jsx";
184+
} else if (ctype?.startsWith("text/tsx")) {
185+
loader = "tsx";
186+
} else if (ctype?.startsWith("text/css")) {
187+
loader = "css";
179188
}
180189
return {
181190
contents,
182-
loader: ext as unknown as Loader,
191+
loader: loader as unknown as Loader,
183192
};
184193
});
185194
},

0 commit comments

Comments
 (0)