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.cgvv.com.cn/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. 關(guān)于nginx location配置的問題,root到底是什么2. angular.js - angular內(nèi)容過長展開收起效果3. 關(guān)于docker下的nginx壓力測試4. angular.js - angularjs的自定義過濾器如何給文字加顏色?5. docker鏡像push報錯6. python - flask表單 如何把提交多行數(shù)據(jù)在服務(wù)端讀取出來?7. python的前景到底有大?如果不考慮數(shù)據(jù)挖掘,機器學(xué)習(xí)這塊?8. python 怎樣用pickle保存類的實例?9. 并發(fā)模型 - python將進(jìn)程池放在裝飾器里為什么不生效也沒報錯10. 大家好,請問在python腳本中怎么用virtualenv激活指定的環(huán)境?
