Parcel build is failing `bundle.scss:undefined:undefined: plugin is not a function`

Viewed 2317

I am using parcel bundler for my learning project and trying to create build for it. I am also using scss file. In bundle.scss I have imported all of my scss files. And importing bundle.scss into App.js.

So while running parcel build index.html, i am getting following error.

  /src/style/bundle.scss:undefined:undefined: plugin is not a function
    at LazyResult.run (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:288:14)
    at LazyResult.asyncTick (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:212:26)
    at /usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:254:14
    at new Promise (<anonymous>)
    at LazyResult.async (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:250:23)
    at LazyResult.then (/usr/local/lib/node_modules/parcel-bundler/node_modules/postcss/lib/lazy-result.js:131:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxxxx complete: `parcel build index.html`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the xxxxx complete script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /.npm/_logs/2021-06-12T17_37_55_156Z-debug.log

My project structure

src/
-App.js
-styles/
--bundle.scss
--app.scss
-index.html

Any suggestion would be real help for me, Thanks.

3 Answers

It seems to be a bug in Parcel's nanocss. I could only fix it by not minifying the css at all, using

parcel build --no-minify

You don't have to remove your minification, there's another way..

you cannot see cssnano version because it's under the hood. There's a bug with the current parcel bundler version & the current cssnano version.

you can fix this by downgrading cssnano

npm uninstall cssnano
npm i -D cssnano@4.1.11

now try rebuilding it with parcel build <your path>, it should work.

You can still use parcel-bundler if you downgrade cssnano to 4.1.11.

Probably the only reason to do this is if you are using Vue SFCs.

Related