javascript - webpack dllPlugin如何打包vendor到html里面?
問題描述
使用html-webpack-plugin只能將應(yīng)用的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='http://www.baoyu77737.com/wenda/<%= htmlWebpackPlugin.optiions.vendor %>'></script></body>
3、 設(shè)置webpack.dev.config.js
//...plugins:[ new HTMLPlugin({template: ’./src/template.html’,filename: ’index.html’vendor: ’/dll/’ + manifest.name + ’.js/’ //manifest就是dll生成的json })]
僅僅用于開發(fā)環(huán)境
相關(guān)文章:
1. java - C語言算法題-韓信點(diǎn)兵 求解?2. html5 - 微信瀏覽器視頻播放失敗3. java - spring-data Jpa 不需要執(zhí)行save 語句,Set字段就可以自動執(zhí)行保存的方法?求解4. javascript - 這問題怎么處理額5. 網(wǎng)頁爬蟲 - Python 爬蟲中如何處理驗(yàn)證碼?6. javascript - jQuery中l(wèi)ive事件在移動微信端下沒有效果;代碼如下7. javascript - SuperSlide.js火狐不兼容怎么回事呢8. javascript - owl.carousel.js這個插件的原作者的網(wǎng)址是多少了?9. phpstady在win10上運(yùn)行10. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項(xiàng)
