-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
But when I upload it to Github pages, the index page has no CSS applied to it:

The strange thing is that CSS get applies correctly on other pages, only the index page (i.e. from src/+page.svelte) has this problem. Even stranger is if I click a link to go to another page, and then click a link coming back to the index page, the CSS will be applied! You can see this on my demo pages. Can anyone explains why this is happening?
The build produce no error of course. It is the final result that is the problem.
There was no such problem before on my old project (built around the time when SvelteKit1.0 comes out). But when I update my npm packages everything breaks. So I start afresh and checked that I really doesn't show the way I expect. If any of my steps is wrong, perhaps some clarification in the documentation will be very helpful. Perhaps some clarification on the correct steps to how to update the svelte packages in the documentation will be helpful too.
Reproduction
Link to the repo containing the demo.
This is how I come to it:
npm create svelte@latest testappnpm installnpm i @sveltejs/adapter-static- change
svelte.config.jsas follows
import adapter from "@sveltejs/adapter-static";
const dev = process.argv.includes("dev");
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter({
pages: "docs",
assets: "docs",
}),
paths: {
base: dev ? "" : "/testapp",
},
},
};
export default config;
- Add
export const prerender=trueto+layout.js - Add
+layout.svelteand style it (this is where the CSS are set). - Add another page
about/+page.svelteto demonstrate that the CSS get applies correctly on the non-index page - Add a blank
.nojekyllto static folder npm run devchecked it is producing the result I wantednpm run buildto built to docs folder- Upload to repo to Github and have Github Page points to docs

- Check result on Github pages
Logs
No response
System Info
System:
OS: Windows 10 10.0.19045
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 2.93 GB / 15.81 GB
Binaries:
Node: 18.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.4.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 111.0.5563.64
Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.63)
Internet Explorer: 11.0.19041.1566
npmPackages:
@sveltejs/adapter-auto: ^2.0.0 => 2.0.0
@sveltejs/adapter-static: ^2.0.1 => 2.0.1
@sveltejs/kit: ^1.5.0 => 1.11.0
svelte: ^3.54.0 => 3.56.0
vite: ^4.0.0 => 4.1.4Severity
annoyance
Additional Information
No response
