Skip to content

Is it possible to import css file to js with preserveModules option enabled? #247

@Kelt-prog

Description

@Kelt-prog

Hi everyone.
Im wondering is it possible to import css files into js using import syntax with preserveModules:true in rollup config?
Bundling all css in one file is not an option, because Im making ui library. Also injecting css to works bad on Nextjs.

Bellow file structure of what Im trying to achieve.
index.js

import "styles.css"

Source files structure
-src
--components
---button
----index.ts
----index.module.css
---link
----index.ts
----index.module.css

Expected transpiled files structure
-lib
--components
---button
----index.js
----index.css
---link
----index.js
----index.css

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions