尝试在webpack中创建两个供应商捆绑包,当我在服务器上运行最终脚本时发生了这个错误:
vendor1.369f8f5….js:1 Uncaught TypeError: Cannot read property 'call' of undefined
at t (vendor1.369f8f5….js:1)
at Object.<anonymous> (main.369f8f5….js:1)
at Object.<anonymous> (main.369f8f5….js:1)
at t (vendor1.369f8f5….js:1)
at Object.<anonymous> (main.369f8f5….js:6)
at t (vendor1.369f8f5….js:1)
at window.webpackJsonp (vendor1.369f8f5….js:1)
at window.webpackJsonp (vendor2.369f8f5….js:1)
at main.369f8f5….js:1
这是我的webpack.config:
entry: {
/* Material Design Lite (https://getmdl.io) */
// '!!style-loader!css-loader!react-mdl/extra/material.min.css',
// 'react-mdl/extra/material.min.js',
/* The main entry point of your JavaScript application */
main:'./main.js',
vendor1:['react','router','mixpanel-browser','react-dom','preact','preact-compat'],
vendor2:['core-js','fastclick','whatwg-fetch','axios',],
// vendor3:['core-js'],
// vendor4:['mixpanel-browser'],
},
...
new webpack.optimize.CommonsChunkPlugin({
name: "vendor1",
chunks:['main'],
minChunks:Infinity,
}),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor2",
chunks:['main'],
minChunks:Infinity,
}),
当我只有一个供应商和一个主要捆绑包时,这完全没问题。但是,我没有为较小的文件大小创建第二个供应商包。在线搜索了解决方案,但没有一个有效。也许这与我的语法有关?
答案 0 :(得分:0)
我不知道我的解决方案是否有效......
您是否会尝试对webpack.optimize.CommonsChunkPlugin
和vendor1
使用单vendor2
。
new webpack.optimize.CommonsChunkPlugin({
name: ["vendor1","vendor2"],
chunks:['main'],
minChunks:Infinity,
}),