简体   繁体   中英

Why does asset building using mini-css-extract-plugin work in development but fail in Heroku build process?

Trying to deploy to Heroku with a node.js and ruby buildpack

Git push to Heroku invokes the buildpacks and the rake asset:precompile task is run

Unfortunately this task is failing during the "Compiling" phase with the error below shown for each css/scss asset file to be deployed

ERROR in ./app/assets/stylesheets/base.css
Module build failed (from ./node_modules/@rails/webpacker/node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: Cannot read property 'tap' of undefined
at ExternalModuleFactoryPlugin.apply (/tmp/build_4b756368/node_modules/@rails/webpacker/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:17:37)
at /tmp/build_4b756368/node_modules/@rails/webpacker/node_modules/webpack/lib/ExternalsPlugin.js:16:63
at Hook.eval [as call] (eval at create (/tmp/build_4b756368/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
at Hook.CALL_DELEGATE [as _call] (/tmp/build_4b756368/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)
at /tmp/build_4b756368/node_modules/webpack/lib/Compiler.js:1028:23
at Hook.eval [as callAsync] (eval at create (/tmp/build_4b756368/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/tmp/build_4b756368/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at Compiler.compile (/tmp/build_4b756368/node_modules/webpack/lib/Compiler.js:1025:28)
at Compiler.runAsChild (/tmp/build_4b756368/node_modules/webpack/lib/Compiler.js:495:8)
at Object.pitch (/tmp/build_4b756368/node_modules/@rails/webpacker/node_modules/mini-css-extract-plugin/dist/loader.js:126:17)
@ ./app/javascript/packs/application.js 6:0-42

I was having the exact same issues and I upgraded to the pre-release version of Webpacker following the instructions here:

https://github.com/rails/webpacker/blob/master/6_0_upgrade.md

That fixed my issue and everything worked after that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM