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.b3g6.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. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. mac里的docker如何命令行開啟呢?4. 關于docker下的nginx壓力測試5. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題6. nignx - docker內nginx 80端口被占用7. docker容器呢SSH為什么連不通呢?8. 如何解決Centos下Docker服務啟動無響應,且輸入docker命令無響應?9. docker start -a dockername 老是卡住,什么情況?10. dockerfile - 我用docker build的時候出現下邊問題 麻煩幫我看一下

網公網安備