Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): dev ssr fouc with preprocessors #916

Closed
wants to merge 2 commits into from
Closed

Conversation

antfu
Copy link
Member

@antfu antfu commented Oct 13, 2021

close nuxt/nuxt#11990

We append &__nuxt_mock.css for preprocessors extensions in the manifest for the renderer to treat it as css and rewrite back on serving.

@netlify
Copy link

netlify bot commented Oct 13, 2021

✔️ Deploy Preview for nuxt3-docs ready!

🔨 Explore the source changes: 370d83f

🔍 Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/6166a917307008000815aaed

😎 Browse the preview: https://deploy-preview-916--nuxt3-docs.netlify.app

@@ -16,7 +16,24 @@ export function uniq<T> (arr: T[]): T[] {
}

const IS_CSS_RE = /\.css(\?[^.]+)?$/
const IS_DEV_CSS_RE = /\.(?:css|scss|sass|postcss|less|stylus|styl)(\?[^.]+)?$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about IS_SRC_CSS_RE or IS_UNPROCESSED_CSS_RE? dev is misleading imo little bit

return file
}
if (file.includes('?')) {
return file + '&' + MOCK_CSS_SUFFIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use withQuery from ufo? It should handle this cases

enforce: 'pre',
configureServer (server) {
server.middlewares.use((req, _, next) => {
if (req.url.endsWith(MOCK_CSS_SUFFIX)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use resolveId hook to fix issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, what about updating regex in vue-bundle-renderer. Would it fix without workaround?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't know we have control of that package. That would defintely better to be fixed there.

@antfu
Copy link
Member Author

antfu commented Oct 13, 2021

Close in favor of nuxt-contrib/vue-bundle-renderer#18

@antfu antfu closed this Oct 13, 2021
@antfu antfu deleted the fix/scss-fouc branch October 13, 2021 13:35
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vite: SCSS Styles doesn't preload in dev
3 participants