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. python - 获取到的数据生成新的mysql表2. javascript - js 对中文进行MD5加密和python结果不一样。3. mysql里的大表用mycat做水平拆分,是不是要先手动分好,再配置mycat4. window下mysql中文乱码怎么解决??5. sass - gem install compass 使用淘宝 Ruby 安装失败,出现 4046. python - (初学者)代码运行不起来,求指导,谢谢!7. 为啥不用HBuilder?8. python - flask sqlalchemy signals 无法触发9. python的文件读写问题?10. 为什么python中实例检查推荐使用isinstance而不是type?
