Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
243 stars 43 forks source link

CSS input, emit raw output to file (no ES parsing) #233

Open drzraf opened 1 year ago

drzraf commented 1 year ago

I'd like to preprocess CSS with rollup + this plugin with no javascript involved (SASS in, CSS out).

{
    input: 'css/index.css',
    output: {
        file: "foo.css",
    },
    plugins: [
      styles({
          include: [/\.css/u],
          use: ['sass'],
          mode: ["emit"],
          minimize: {preset: 'default'},
      })
    ]
}

I tried any possible option to entirely disable output postprocessing:

        sourcemap: false,
        compact: false,
        esModule: false,
        minifyInternalExports: false,
        generatedCode: e => e,
        plugins: []

but I can't get the CSS to be stored because rollup does tryParse :

css/index.css → foo.css...
css/index.css (1:80)
[!] RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)
html{-webkit-tex...
*/

I tried to add a dummy plugin to disable this:
```js
        {
        transform(code, _id) {
        return {ast: code, code, map: null, moduleSideEffects: false};
        }
        }

but still doesn't keep rollup this.hasEffects(createHasEffectsContext())); from running and triggering an error.

How to achieve this?