Skip to content

Commit

Permalink
chore(vite): dynamically import getStylesForUrl and readConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <[email protected]>
  • Loading branch information
mcansh committed Nov 16, 2023
1 parent 1ec807d commit 5182372
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/unstable-vite/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
unstable_createViteServer,
unstable_loadViteServerBuild,
} from "@remix-run/dev";
import { getStylesForUrl } from "@remix-run/dev/dist/vite/styles.js";
import { readConfig } from "@remix-run/dev/dist/config.js";

installGlobals();

Expand Down Expand Up @@ -73,6 +71,11 @@ app.all("*", async (request, reply) => {
let criticalCss;

if (vite) {
let [{ getStylesForUrl }, { readConfig }] = await Promise.all([
import("@remix-run/dev/dist/vite/styles.js"),
import("@remix-run/dev/dist/config.js"),
]);

let remixConfig = await readConfig();
let resolvedBuild = vite ? await build() : build;
criticalCss = await getStylesForUrl(
Expand Down

0 comments on commit 5182372

Please sign in to comment.