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. android - 优酷的安卓及苹果app还在使用flash技术吗?2. 为什么redis中incr一个“0” 会报错?3. python - 使用scrapy框架爬百度图片被墙4. css内联样式的style5. css - input中transition 设置background-color过渡,chrome浏览器页面初始化渲染会有过度效果6. HTML表单操作标签调用父相对URL7. javascript - webpack异步加载js问题8. nginx - 关于vue项目部署到ngnix后出现的问题9. 网页文字默认显示固定行数,点击按钮显示全部怎么实现?10. java - 一个泛型标签问题

网公网安备