javascript - webpack dllPlugin如何打包vendor到html里面?
问题描述
使用html-webpack-plugin只能将应用的bundle.js写到html,不能将dll生成的vendor写入,有没有什么办法?
问题解答
回答1:可以使用 add-asset-html-webpack-plugin,将打包后的文件,加入html中。通过以下方式引用,或者参考下我的vue-2.0template
喜欢的话可以给个star
new HtmlWebpackPlugin({ filename: itemPath, template: template, inject: true, title: item.title || ’Document’, chunks: chunks, chunksSortMode: ’dependency’,}),new AddAssetHtmlPlugin([{ filepath: path.resolve(__dirname, config.build.dll.basePath, config.build.dll.fileName), outputPath: utils.assetsPath(’common/js/’), publicPath: path.join(config.build.publicPath, ’common/js’), includeSourcemap: true}])回答2:
自问自答:1、 将vendor.js生成到/dll/,2、 template.html使用html-webpack-plugin的模板语法
<body><script src='https://www.haobala.com/wenda/<%= htmlWebpackPlugin.optiions.vendor %>'></script></body>
3、 设置webpack.dev.config.js
//...plugins:[ new HTMLPlugin({template: ’./src/template.html’,filename: ’index.html’vendor: ’/dll/’ + manifest.name + ’.js/’ //manifest就是dll生成的json })]
仅仅用于开发环境
相关文章:
1. javascript - sublime快键键问题2. javascript - vue中input的blur影响了下拉的点击事件如何解决3. docker 17.03 怎么配置 registry mirror ?4. mysql插入文本如果是个sql语句就报错了5. node.js通过module.exprots返回的是promise对象而非data?6. javascript - 微信小程序 如何实现这种左滑动出现删除的办法?有相关api吗?7. python打开.py文件的时候出现window无法打开该文件是怎么回事呢?8. javascript - swiper插件loop模式下的BUG?9. docker gitlab 如何git clone?10. css - 如何讓圖片像雲一樣的行為?

网公网安备