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='http://www.gepszalag.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. PHP單例模式2. javascript - 微信報redirect_uri參數錯誤3. node.js - webstorm中下載mongoose的錯誤4. 我在centos容器里安裝docker,也就是在容器里安裝容器,報錯了?5. android - 類似微信朋友圈或者QQ空間說說那種點擊圖片放大,并且有放大縮小手勢,左右滑動圖片手勢效果6. win10系統 php安裝swoole擴展7. html5 - 如何禁止百度轉碼?8. html5 - css3 scale 從0到1在有的手機上,圖像會變模糊9. 黑客 - Python模塊安全權限10. 網頁動畫等過渡效果,CSS3 transitions 和 jQuery animations 誰實現的性能更好?
