7rulnik / postcss-flexibility

PostCSS plugin for Flexibility polyfill
MIT License
296 stars 14 forks source link

Error "[object Object] is not a PostCSS plugin" when using with Laravel Mix #145

Open Nikschavan opened 2 years ago

Nikschavan commented 2 years ago

Laravel Mix internally uses webpack and allows you to add postcss plugins.

I am trying to use it with postcss-flexibility, although I am seeing this following error log - This error only happens with this postcss plugin, I tried a few other plugins and this error does not seem to occur.

✖ Mix
  Compiled with some errors in 296.11ms

ERROR in ./sass/site/navigation/menu-animation.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
Error: [object Object] is not a PostCSS plugin
    at Processor.normalize (/Users/Nik/Projects/path/to/node_modules/postcss/lib/processor.js:63:15)
    at new Processor (/Users/Nik/Projects/path/to/node_modules/postcss/lib/processor.js:10:25)
    at postcss (/Users/Nik/Projects/path/to/node_modules/postcss/lib/postcss.js:26:10)
    at Object.loader (/Users/Nik/Projects/path/to/node_modules/postcss-loader/dist/index.js:96:17)
    at processResult (/Users/Nik/Projects/path/to/node_modules/webpack/lib/NormalModule.js:701:19)
    at /Users/Nik/Projects/path/to/node_modules/webpack/lib/NormalModule.js:807:5
    at /Users/Nik/Projects/path/to/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /Users/Nik/Projects/path/to/node_modules/loader-runner/lib/LoaderRunner.js:251:18
    at context.callback (/Users/Nik/Projects/path/to/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
    at Object.loader (/Users/Nik/Projects/path/to/node_modules/postcss-loader/dist/index.js:142:7)

1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
Nikschavan commented 2 years ago

I have reproduced this in this repo - https://github.com/Nikschavan/laravel-mix-error

You can clone this repo, run npm install and then npm run build to se the error. I was able to fix this error with some changes in the plugin definition by checking the postcss blilerplate plugin although I am not sure if this is the right approach, would love to get some feedback.

Nikschavan commented 2 years ago

I am getting similar error when using this in grunt with @lodder/grunt-postcss

Warning: [object Object] is not a PostCSS plugin Use --force to continue.

The PR #146 seems to be fixing this when using it with grunt as well.