I got webpacker error when running the rails app. 'TypeError: environment.plugins.set is not a function'
I got webpacker error when running the rails app. 'TypeError: environment.plugins.set is not a function'
Rails 5.1.5
webpacker 3.3.0
当我 运行 rails 应用程序时,出现此编译错误并且无法运行。
Compilation failed:
remote: /tmp/build_074ca0ee678491d6f72035c60cc5f616/config/webpack/environment.js:5
remote: environment.plugins.set('Provide',
remote: ^
remote: TypeError: environment.plugins.set is not a function
remote: at Object.<anonymous> (/tmp/build_074ca0ee678491d6f72035c60cc5f616/config/webpack/environment.js:5:21)
remote: at Module._compile (module.js:643:30)
我自己找到了解决方案。
已将 set
更改为 config/webpack/environment.js
的 prepend
。
之前
environment.plugins.set('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
)
之后
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
)
https://github.com/rails/webpacker/issues/1318
https://github.com/rails/webpacker/blob/master/CHANGELOG.md#330---2018-03-03
Rails 5.1.5 webpacker 3.3.0
当我 运行 rails 应用程序时,出现此编译错误并且无法运行。
Compilation failed:
remote: /tmp/build_074ca0ee678491d6f72035c60cc5f616/config/webpack/environment.js:5
remote: environment.plugins.set('Provide',
remote: ^
remote: TypeError: environment.plugins.set is not a function
remote: at Object.<anonymous> (/tmp/build_074ca0ee678491d6f72035c60cc5f616/config/webpack/environment.js:5:21)
remote: at Module._compile (module.js:643:30)
我自己找到了解决方案。
已将 set
更改为 config/webpack/environment.js
的 prepend
。
之前
environment.plugins.set('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
)
之后
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
)
https://github.com/rails/webpacker/issues/1318 https://github.com/rails/webpacker/blob/master/CHANGELOG.md#330---2018-03-03