Skip to content

Support the direct query param #341

@matthewp

Description

@matthewp

Describe the problem

In Astro we prefer to add <link> tags per component for styles in development mode. This works because Vite will detect a request that has been added via link tag through the Accept header and then injects the direct query param.

For Astro and Vue styles this works because those Vite plugins do not modify the id. Since Svelte creates an id the direct param gets lost.

This means that we cannot use <link> in dev for Svelte, but rather must use a module script which results in a FOUC (flash of unstyled content).

Describe the proposed solution

When generating the cssId, preserve direct query param, if it's included in the importee.

const cssId = createVirtualImportId(filename, root, 'style');

Alternatives considered

No alternatives that I am aware of, other than Astro continuing to use <script> and live with the FOUC.


Note that I am willing to submit a PR for this.

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions