Anidetrix / rollup-plugin-styles

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

fix: emitFile error when some file content is empty #220

Open richerfu opened 1 year ago

richerfu commented 1 year ago

https://github.com/southorange1228/rollup-style-demo

Just like this demo, if less file content is empty, the file can't be created which source file content is empty.

And i changed rollup-plugin-style.

// before
        const cssFile = {
          type: "asset",
          name: res.name,
          source: res.css
        };
        const cssFileId = this.emitFile(cssFile);
// after
        const cssFile = {
          type: "asset",
          fileName: res.name,
          name: res.name,
          source: res.css
        };
        const cssFileId = this.emitFile(cssFile);

And this problem can be fixed.