从Webpack 3迁移到Webpack 4 [英] Migrating to Webpack 4 from Webpack 3
问题描述
我正在尝试迁移到Webpack 4,但这真的很痛苦。在将Webpack 3插件移动到Webpack 4原生内容之后的几天,我得到 js
,据说可以正常呈现,但是当我访问我的网站时,我收到了这条消息在控制台上:
I am trying to migrate to Webpack 4, but is has been a real pain. After couple of days working on moving Webpack 3 plugins to Webpack 4 native stuff, I got the js
to be rendered fine supposedly, but when I go to my website I got this message on the console:
未捕获TypeError :(中间值)(中间值).push不是函数
开:
(window [webpackJsonp] = window [webpackJsonp ] || [])。push([[Index],{
这是我的Webpack 输出
设置:
This is my Webpack output
settings:
output: {
filename,
path: path.resolve(__dirname, 'public', 'build', 'js'),
jsonpFunction: 'webpackJsonp', // TODO gotta figure that out
},
我做错了什么?
推荐答案
刚刚遇到同样的问题我找到了这个帖子 https://github.com/webpack / webpack / issues / 6985
Just had the same issue and I have found this thread https://github.com/webpack/webpack/issues/6985
当您将模块与 Webpack 捆绑在一起时,似乎会发生这种情况。 4.如果有任何帮助,我会在这里张贴。
It seems to happen when you have modules bundled with Webpack < 4. I'm posting it here if it can be of any help.
更改 output.jsonpFunction
< a href =https://webpack.js.org/configuration/output/#output-jsonpfunction =nofollow noreferrer> https://webpack.js.org/configuration/output/#output-jsonpfunction 到 jsonpFunction
解决了它:
{
output: {
jsonpFunction: 'jsonpFunction',
...
}
}
信用转到@sokra(Webpack的创建者): https://github.com/webpack/webpack/issues/6985#issuecomment-380795070
Credit goes to goes to @sokra (the creator of Webpack): https://github.com/webpack/webpack/issues/6985#issuecomment-380795070
这篇关于从Webpack 3迁移到Webpack 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!