rollup-plugin-styles icon indicating copy to clipboard operation
rollup-plugin-styles copied to clipboard

`preserveModules`, but keep and entry point with `@import`

Open fregante opened this issue 6 months ago • 0 comments

I'm trying to use preserveModules: true primarily for JS code, but this has a confusing output for CSS files.

Input

/* main.js */
import './alpha.css';
import './beta.css';
console.log('hi')
/* alpha.css */
html {color: red;}
/* beta.css */
body {font-weight: bold}

Current output

/* main.js */
console.log('hi')
/* main.css */
html {color: red;}
body {font-weight: bold}
/* alpha.css */
html {color: red;}
/* beta.css */
body {font-weight: bold}

Expected output

One of:

  • only main.css (ignoring preserveModule, which I don't need for CSS)
  • alpha.css, beta.css, and a main.css that looks like @import 'alpha.css';@import 'beta.css'

Final notes

I'm mostly ok with the current behavior as the duplicate CSS is minor and inert, but I'm afraid that this is considered a "bug" and it might be "fixed" in a way that doesn't match my expectations (i.e. main.css is no longer created or it's empty, without imports)

Related

  • https://github.com/Anidetrix/rollup-plugin-styles/issues/130

fregante avatar Aug 19 '24 15:08 fregante