Skip to content

Commit

Permalink
fix: switch to side-effecting imports of app.css
Browse files Browse the repository at this point in the history
This resolves a hydration error on production,
due to different app.css resulting build asset url
  • Loading branch information
azzzy committed Jan 24, 2025
1 parent c4063b1 commit 1329f79
Show file tree
Hide file tree
Showing 17 changed files with 1,566 additions and 130 deletions.
3 changes: 1 addition & 2 deletions cloudflare-d1/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-router";

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import "./app.css";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand All @@ -21,7 +21,6 @@ export const links: Route.LinksFunction = () => [
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
{ rel: "stylesheet", href: stylesheet },
];

export function Layout({ children }: { children: React.ReactNode }) {
Expand Down
2 changes: 1 addition & 1 deletion cloudflare-d1/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default defineConfig(({ isSsrBuild }) => ({
cloudflareDevProxy({
getLoadContext,
}),
tailwindcss(),
reactRouter(),
tsconfigPaths(),
tailwindcss(),
],
}));
3 changes: 1 addition & 2 deletions cloudflare/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-router";

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import "./app.css";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand All @@ -21,7 +21,6 @@ export const links: Route.LinksFunction = () => [
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
{ rel: "stylesheet", href: stylesheet },
];

export function Layout({ children }: { children: React.ReactNode }) {
Expand Down
2 changes: 1 addition & 1 deletion cloudflare/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default defineConfig(({ isSsrBuild }) => ({
return { cloudflare: context.cloudflare };
},
}),
tailwindcss(),
reactRouter(),
tsconfigPaths(),
tailwindcss(),
],
}));
5 changes: 0 additions & 5 deletions default/app/app.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
@import "tailwindcss";

@theme {
--font-sans: 'Inter', ui-sans-serif, system-ui, sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}

html,
body {
@apply bg-white dark:bg-gray-950;
Expand Down
3 changes: 1 addition & 2 deletions default/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-router";

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import "./app.css";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand All @@ -21,7 +21,6 @@ export const links: Route.LinksFunction = () => [
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
{ rel: "stylesheet", href: stylesheet },
];

export function Layout({ children }: { children: React.ReactNode }) {
Expand Down
1 change: 1 addition & 0 deletions default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@types/node": "^20",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"react-router-devtools": "^1.1.0",
"tailwindcss": "^4.0.0",
"typescript": "^5.7.2",
"vite": "^5.4.11",
Expand Down
7 changes: 5 additions & 2 deletions default/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
plugins: [reactRouter(), tsconfigPaths(), tailwindcss()],
});
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
build: {
cssMinify: true,
ssr: false,
}});
3 changes: 1 addition & 2 deletions netlify/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-router";

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import "./app.css";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand All @@ -21,7 +21,6 @@ export const links: Route.LinksFunction = () => [
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
{ rel: "stylesheet", href: stylesheet },
];

export function Layout({ children }: { children: React.ReactNode }) {
Expand Down
2 changes: 1 addition & 1 deletion netlify/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default defineConfig(({ isSsrBuild }) => ({
}
: undefined,
},
plugins: [reactRouter(), tsconfigPaths(), tailwindcss()],
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
}));
3 changes: 1 addition & 2 deletions node-custom-server/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-router";

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import "./app.css";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand All @@ -21,7 +21,6 @@ export const links: Route.LinksFunction = () => [
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
{ rel: "stylesheet", href: stylesheet },
];

export function Layout({ children }: { children: React.ReactNode }) {
Expand Down
2 changes: 1 addition & 1 deletion node-custom-server/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default defineConfig(({ isSsrBuild }) => ({
}
: undefined,
},
plugins: [reactRouter(), tsconfigPaths(), tailwindcss()],
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
}));
3 changes: 1 addition & 2 deletions node-postgres/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react-router";

import type { Route } from "./+types/root";
import stylesheet from "./app.css?url";
import "./app.css";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand All @@ -21,7 +21,6 @@ export const links: Route.LinksFunction = () => [
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
{ rel: "stylesheet", href: stylesheet },
];

export function Layout({ children }: { children: React.ReactNode }) {
Expand Down
2 changes: 1 addition & 1 deletion node-postgres/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default defineConfig(({ isSsrBuild }) => ({
}
: undefined,
},
plugins: [reactRouter(), tsconfigPaths(), tailwindcss()],
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
}));
Loading

0 comments on commit 1329f79

Please sign in to comment.