-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flash of unstyled content in dev mode #915
Comments
This sounds like it could be coming from vitejs/vite#2282 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hi all. This issue has been getting a lot of comments related to a bug in Svelte core that was fixed with Svelte 3.40.0 and SvelteKit 1.0.0-next.135. I'm hiding many of the most recent comments as off-topic because they're unrelated to the original SvelteKit issue here that existed before the Svelte bug was introduced |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I've got a similar issue with a scss file imported in routes/__layout.svelte It seems that it does not load those styles in a render blocking manner. Dependencies"@sveltejs/kit": "1.0.0-next.158" computer macOs Catalina |
This comment has been minimized.
This comment has been minimized.
If it helps anyone.. i found that my FOUC was only happening when I had references to CSS in my app.html |
We have the same issue on our project. The CSS is not in the EDIT: issue was solved by renaming the |
I have the same problem with latest svelte kit:
This is what I get (10sec pause on a frame so possible to read): What I notices is that Does not matter if I build it, or if I use it in dev - same behavior. This is part of my
and this is part of
|
I'm running into this issue, as well. Working off of the base SvelteKit project. When I rename svelte.config.js
postcss.config.cjs
|
I get this issue as well svelte.config.js import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: [
preprocess({
postcss: true,
}),
],
kit: {
adapter: adapter(),
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte',
},
};
export default config; postcss.config.cjs const tailwindcss = require('tailwindcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const mode = process.env.NODE_ENV;
const dev = mode === 'development';
const config = {
plugins: [
tailwindcss(), // first load TailwindCSS
autoprefixer(), // then run autoprefixer
!dev && // optimize the code for production
cssnano({
preset: 'default',
}),
],
};
module.exports = config; tailwind.config.cjs const config = {
mode: 'jit',
content: ['./src/**/*.{html,js,svelte,ts}'],
theme: {
extend: {},
},
// Only add this if you installed the TailwindCSS-plugins:
plugins: [require('@tailwindcss/typography'), require('@tailwindcss/forms')],
};
module.exports = config; index.svelte <script>
// src/routes/__layout.svelte
import "../app.pcss";
</script>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> If I rename index.svelte <script>
// src/routes/__layout.svelte
import "../app.css"; // Changed from .pcss
</script>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p> |
I have this problem as well, in both development and production. I'm using Tailwind and Carbon components (which requires SCSS). Edit: I was missing an adapter; after adding it, the problem is mitigated (but not solved) for production. It still flashes occasionally, just more briefly. |
This comment has been minimized.
This comment has been minimized.
I found the answer everyone! Give that person a thumbs up! No need to modify your More explicitly, remove this from the top of import '../app.scss'; And add this to the bottom: <style lang="scss" global>
@import '../app.scss';
</style> |
@skrenes that did it—thanks! Only thing is it threw an error that I can only have one top-level |
Yeah, I guess while it feels dirty polluting the global styles, |
So if anyone else comes across this issue while using __layout.reset.svelte it's important to import '../app.css' (or in my case in a subfolder import '../../app.css'; however nested your layout reset might be) in your layout reset component. I had created this layout from scratch and hadn't included that so I was getting a nasty FOUC. 😅 If it's helpful, look at how your root level __layout.svelte file is doing this import, and mimic that in your reset file. |
Alright, I figured out what's going on here. Turns out I even anticipated this bug and added a TODO at some point: kit/packages/kit/src/core/dev/plugin.js Lines 82 to 86 in 623fa49
The easy fix would be to just add |
Vite has a hardcoded list of CSS langs too. There isn't an API or trick to share the code from Vite, so a compromise now is to copy it over. |
I can't think of a better solution than hardcoding the CSS variants in. Given that the smart people over at Vite haven't come up with anything either, I think it may be the best choice. One possibility would be to hardcode our list here, leaving a TODO to revisit it occasionally to see if there's a better way -- better to provide a stable fix now (I mean, really, how often is there a new CSS filetype variant) and perhaps revisit later... If we want to go with the hardcoded approach, I can work up a pull request. |
I didn't have the flash of unstyled in dev before #4882, but now I do :-( |
@gaarf can you file a new issue with steps to reproduce and then link to it from here? We'd need more info... |
@benmccann @Conduitry after cleaning build and updating to |
Describe the bug
Css feels wierd while reload in dev environment. Works fine with build output
To Reproduce
Using below dependencies:
"@sveltejs/adapter-node": "next",
"@sveltejs/kit": "next",
"svelte": "^3.29.0",
"vite": "^2.1.0"
Video
css_wierd_on_reload.mp4
The text was updated successfully, but these errors were encountered: