nonzzz / vite-plugin-stylex

an unofficial @stylexjs vite support
MIT License
45 stars 4 forks source link

Preload styles via <link rel="stylesheet" /> #11

Closed predaytor closed 1 month ago

predaytor commented 4 months ago

With Vite's future support for .css?url imports, will it be possible to enable manual preloading for styles? For example, using Remix:

export const links = () => [
    // Preload CSS as a resource to avoid render blocking
    { rel: 'preload', href: stylesHref, as: 'style' },

    // These should match the css preloads above to avoid css as render blocking resource
    { rel: 'stylesheet', href: stylesHref },
];
nonzzz commented 4 months ago

Well,Is there any document or information for this feature request? I'm currently can't get any information about .css?url from vite document. I think we need more details.

nonzzz commented 4 months ago

Currently, for production mode, the plugin injects style behavior using vite's css-post plugin. This means that the insertion order and injected tag attributes are controlled by vite. I assume this feature request is for SSR. If vite supports .css?url in the future, I can support it.

predaytor commented 4 months ago

Sorry I didn't mention it, here is the PR: https://github.com/vitejs/vite/pull/15259. Thanks for reply. Looking forward to use StyleX on the next project.

predaytor commented 3 months ago

With the release of Vite 5.1, how can we implement this?

nonzzz commented 3 months ago

Well, I'll do it as soon as possible.

nonzzz commented 1 month ago

@predaytor See remix-demo get more information.

nonzzz commented 1 month ago

I think this feature is already supported. Can we turn it off?

predaytor commented 1 month ago

All is working perfectly, HMR, everything! Very thx!