Skip to content

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

@drzraf

Description

@drzraf

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?

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