Skip to content

Css not getting imported #195

@soerenmeier

Description

@soerenmeier

Describe the bug

Today i ran into a weird behaviour, which took a few minutes to debug, my folder structure:

  • keyboard.svelte
  • keyboard.js
  • keyboard.css

Where the js file is a custom dom component which is styled in keyboard.css, then everything is nicely packed into a svelte component in keyboard.svelte.
but importing the style with import './keyboard.css'; in keyboard.svelte or keyboard.js did nothing. After digging around a bit i found that svelte gives the css/styles inside keyboard.svelte the id: './keyboard.css' (in the plugin transform call). rollup-plugin-css-only then skip's my file keyboard.css entirely. After renaming it everything works as expected.
Would be nice if svelte would rename the id if a file already exists with that name or at least show a warning.

Reproduction

Create a svelte component and a css file with the same name for example:

  • component.svelte
  • component.css

Then import the css in component.svelte.

Logs

No warning or error.

System Info

System:
    OS: Linux 5.13 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 18.93 GB / 31.27 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 17.3.1 - /usr/bin/node
    npm: 8.3.0 - /usr/bin/npm
  Browsers:
    Chromium: 98.0.4758.80
    Firefox: 96.0
  npmPackages:
    rollup: ^2.3.4 => 2.66.1 
    svelte: ^3.0.0 => 3.46.3

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions