Skip to content

Commit

Permalink
[fix] stop flash of unstyled content when using CSS flavours (#4882)
Browse files Browse the repository at this point in the history
* [fix] stop flash of unstyled content when using CSS flavours

* Create cuddly-knives-learn.md

* fix

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
benmccann and Rich-Harris authored May 12, 2022
1 parent e4892d4 commit c8e9822
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-knives-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/kit": patch
---

[fix] stop flash of unstyled content when using CSS flavours
7 changes: 5 additions & 2 deletions packages/kit/src/core/dev/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { sequence } from '../../hooks.js';
import { posixify } from '../../utils/filesystem.js';
import { parse_route_id } from '../../utils/routing.js';

// Vite doesn't expose this so we just copy the list for now
// https://github.com/vitejs/vite/blob/3edd1af56e980aef56641a5a51cf2932bb580d41/packages/vite/src/node/plugins/css.ts#L96
const style_pattern = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/;

/**
* @param {import('types').ValidatedConfig} config
* @param {string} cwd
Expand Down Expand Up @@ -78,9 +82,8 @@ export async function create_plugin(config, cwd) {
const parsed = new URL(dep.url, 'http://localhost/');
const query = parsed.searchParams;

// TODO what about .scss files, etc?
if (
dep.file.endsWith('.css') ||
style_pattern.test(dep.file) ||
(query.has('svelte') && query.get('type') === 'style')
) {
try {
Expand Down

0 comments on commit c8e9822

Please sign in to comment.