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. 如何解决docker宿主机无法访问容器中的服务?2. javascript - 微信jssdk ios下自定义onMenuShareAppMessage 分享失效,Android分享成功3. 老师百度网盘分享一下WampServer的包啊,我们下载几kb要下载一天的.4. java - 如图,同样一个表单,为什么用myeclipse内置的浏览器提交就会自动编码,用chrome浏览器就不会自动编码?5. node.js - windows下安装webpack时出现路径问题如何解决?6. 关于java 泛型设计接口 导致的参数类型不匹配问题7. javascript - vue中更改state的值8. SQLAlchemy 访问Mysql数据库弹出Warning,VARIABLE_VALUE,如何解决?9. java - 如何修改Eclipse项目那一块的背景颜色?10. vue.js - linux下怎么使用vue-cli的vue命令
