vuejs / vue-component-compiler

Compile a single file Vue component into a CommonJS module.
MIT License
342 stars 52 forks source link

PostCSS 8 deprecates `postcss.plugin` #110

Open halostatue opened 3 years ago

halostatue commented 3 years ago

I’m running with rollup-plugin-vue and vue-component-compiler provides a plugin, postcss-clean that causes this message to be output:

clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration

This appears to work fine for now, but the API used on postcss-clean.ts:6 is deprecated.

lgollut commented 2 years ago

Since this package is unlikely to be patched, I used https://www.npmjs.com/package/patch-package to silence the warning

-exports.default = postcss.plugin('clean', (options) => {
+exports.default = (options) => {
     const clean = new CleanCSS(Object.assign({ compatibility: 'ie9' }, options));
-    return (css, res) => {
+    return {
+      postcssPlugin: 'clean',
+      Once(css, res) {
         const output = clean.minify(css.toString());
         res.root = postcss.parse(output.styles);
+      },
     };
-});
+};
+exports.postcss = true