Javascript Webpack 3和CommonChunkPlugin-从要求的供应商中排除特定入口点
我正在开发一个大型的商业软件,它正在慢慢地迁移到所有页面上使用Webpack。我想开始将一些webpack捆绑的helper typescript代码合并到尚未开始使用webpack的页面中-它们以老式的方式包含脚本 以下是配置的相关部分:Javascript Webpack 3和CommonChunkPlugin-从要求的供应商中排除特定入口点,javascript,webpack,Javascript,Webpack,我正在开发一个大型的商业软件,它正在慢慢地迁移到所有页面上使用Webpack。我想开始将一些webpack捆绑的helper typescript代码合并到尚未开始使用webpack的页面中-它们以老式的方式包含脚本 以下是配置的相关部分: entry: { vendor: [ // All vendor scripts go here ], // All entry points for 'webpack' pages... // A spe
entry: {
vendor: [
// All vendor scripts go here
],
// All entry points for 'webpack' pages...
// A special entry point that I want to inject into non-webpack pages
es5Compatibility: [
'Utility/ES5Compatibility.ts'
]
},
// ...
output: {
path: path.join(__dirname, 'Scripts/bundle'),
filename: '[name].[chunkhash].bundle.js',
chunkFilename: '[id].chunk.js'
},
plugins: [
// ...
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
})
// This should NOT get injected into non-webpack pages, as all of the
// vendor dependencies already exist there
new HtmlWebpackPlugin({
chunks: ['vendor'],
template: 'bundleTemplate.ejs',
inject: false,
filename: '_VendorBundle.html'
}),
// This should get injected into non-webpack pages WITHOUT requiring
// the above bundle to be included
new HtmlWebpackPlugin({
chunks: ['es5Compatibility'],
template: 'bundleTemplate.ejs',
inject: false,
filename: '_ES5CompatibilityBundle.html'
}),
// ...
new webpack.HashedModuleIdsPlugin(),
]
问题是,当\u ES5CompatibilityBundle.html
包含在没有VendorBundle.html
的页面中时,我会收到以下Javascript错误,因为Webpack希望包含供应商包:
Uncaught ReferenceError: webpackJsonp is not defined
我如何告诉Webpack将ES5兼容性捆绑包捆绑为“自包含”捆绑包,同时保留Webpack页面的commons区块功能