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 - thymeleaf模板 只有length如何循环生成标签?2. 点字符“” 在MVC Web API 2中进行请求,例如api / people / STAFF.452873. javascript - node如何关闭主进程后 打开另一进程?4. 求大神指点js修改margintop导致无限下滑的问题5. node.js - 我是一个做前端的,求教如何学习vue,node等js引擎?6. golang - 用IDE看docker源码时的小问题7. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?8. java - 在Spring初始化过程中阻塞合理吗?9. web服务器 - ubuntu下布置apache加wsgi加python10. python2.7为什么点击了"开始"按钮后,tkinter上的按钮,图中红色部分,再也点不动了?

网公网安备