Webpack入門教程二十九

來源:互聯網
上載者:User

標籤:webpack入門教程十九二十九

133.在模板中以內聯的形式引用script指令碼,修改webpack.config.js檔案,代碼如下
var htmlWebpackPlugin = require("html-webpack-plugin");module.exports = {entry:{main:‘./src/script/main.js‘,a:‘./src/script/a.js‘},output:{path:‘./dist‘,filename:‘js/[name]-[hash].js‘,publicPath:‘http://cdn.com/‘},plugins:[new htmlWebpackPlugin({template:‘index.html‘,filename:‘a.html‘,inject:false,title:‘this is a.html‘}),new htmlWebpackPlugin({template:‘index.html‘,filename:‘b.html‘,inject:false,title:‘this is b.html‘}),new htmlWebpackPlugin({template:‘index.html‘,filename:‘c.html‘,inject:false,title:‘this is c.html‘})]}
134.修改模板檔案index.html,代碼如下
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title><%= htmlWebpackPlugin.options.title %></title><link rel="stylesheet" href=""><script type="text/javascript"><%= compilation.assets[htmlWebpackPlugin.files.chunks.main.entry.substr(htmlWebpackPlugin.files.publicPath.length)].source() %></script></head><body></body></html>

650) this.width=650;" src="https://s1.51cto.com/wyfs02/M02/8D/CB/wKiom1iq0EHCDlz5AACVwJUCSk8259.png-wh_500x0-wm_3-wmp_4-s_3167873831.png" title="QQ20170220191644.png" alt="wKiom1iq0EHCDlz5AACVwJUCSk8259.png-wh_50" />

135.使用cnpm run webpack命令重新打包

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M00/8D/CB/wKiom1iq0FnhB45MAACRHgDdS-M846.png-wh_500x0-wm_3-wmp_4-s_3992230382.png" title="QQ20170220191708.png" alt="wKiom1iq0FnhB45MAACRHgDdS-M846.png-wh_50" />

136.查看產生的a.html,b.html,c.html檔案

650) this.width=650;" src="https://s3.51cto.com/wyfs02/M02/8D/C9/wKioL1iq0IeypVKsAAD_Eaz3ANY617.png-wh_500x0-wm_3-wmp_4-s_4175582340.png" title="QQ20170220191755.png" alt="wKioL1iq0IeypVKsAAD_Eaz3ANY617.png-wh_50" />


650) this.width=650;" src="https://s1.51cto.com/wyfs02/M00/8D/C9/wKioL1iq0NDzWi65AAD6coNBti0285.png-wh_500x0-wm_3-wmp_4-s_2425577470.png" title="QQ20170220191905.png" alt="wKioL1iq0NDzWi65AAD6coNBti0285.png-wh_50" />


650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/8D/CB/wKiom1iq0K6Si3RjAAD9ep4Qquo737.png-wh_500x0-wm_3-wmp_4-s_307981564.png" title="QQ20170220191833.png" alt="wKiom1iq0K6Si3RjAAD9ep4Qquo737.png-wh_50" />



Webpack入門教程二十九

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.