Dan*_*iel 5 javascript webpack
我正在研究一大块商业软件,这些软件正在慢慢迁移到所有页面上使用Webpack.我想开始将一些webpack-bundled helper typescript代码合并到尚未开始使用webpack的页面中 - 它们以老式的方式包含脚本.
以下是配置的相关部分:
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(),
]
Run Code Online (Sandbox Code Playgroud)
问题是,当_ES5CompatibilityBundle.html包含在没有的页面中时VendorBundle.html,我得到以下Javascript错误,因为Webpack期望包含供应商包:
Uncaught ReferenceError: webpackJsonp is not defined
Run Code Online (Sandbox Code Playgroud)
如何告诉Webpack将ES5兼容包捆绑为"自包含"包,同时保留webpack页面的公共块功能?
| 归档时间: |
|
| 查看次数: |
214 次 |
| 最近记录: |