Skip to content

browserlist cant load config for virtual css files #14

Closed
@days-later

Description

@days-later

Description

if you configure vite to use postcss+autoprefixer, at some point svelte's virtual css files will be processed.
browserlist will see the cssId from

const cssId = createVirtualImportId(normalizedFilename, 'style', timestamp);

looks something like "/src/App.svelte.css?svelte&type=style"

browserlist cant resolve that path to find a package.json / .browserslistrc and uses default settings.

Reproduction

https://github.com/days-later/vite-plugin-svelte-test

  • npm run build
  • css in dist/assets/index.xxxx.css is not prefixed

Additional Information

to solve the issue:

  • set browserlist explicitly with autoprefixers overrideBrowserslist option
  • change cssId, eg:
    const cssId = root + createVirtualImportId(normalizedFilename, 'style', timestamp);
    ... not sure if that has side effects. (when using '.' instead of root, rollup tries to load the file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions