Webpack入門教程二十七

來源:互聯網
上載者:User

標籤:webpack入門教程二十七

126.使用同一模板檔案產生不同檔案且標題不同,修改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‘,},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‘})]}
127.修改模板檔案index.html,代碼如下

650) this.width=650;" src="https://s1.51cto.com/wyfs02/M00/8D/C8/wKioL1iqvNODYdFZAABxVFEJ41c414.png-wh_500x0-wm_3-wmp_4-s_51455211.png" title="QQ20170220175343.png" alt="wKioL1iqvNODYdFZAABxVFEJ41c414.png-wh_50" />

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

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M02/8D/CA/wKiom1iqvQfzEO7QAACPGFbOPD4520.png-wh_500x0-wm_3-wmp_4-s_171669827.png" title="QQ20170220175443.png" alt="wKiom1iqvQfzEO7QAACPGFbOPD4520.png-wh_50" />

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

650) this.width=650;" src="https://s5.51cto.com/wyfs02/M00/8D/C8/wKioL1iqvVPwWI8dAABkXSoRC8E071.png-wh_500x0-wm_3-wmp_4-s_1285424707.png" title="QQ20170220175557.png" alt="wKioL1iqvVPwWI8dAABkXSoRC8E071.png-wh_50" />

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/8D/C8/wKioL1iqvWiB5D26AABnMv4XxKI850.png-wh_500x0-wm_3-wmp_4-s_2305478615.png" title="QQ20170220175619.png" alt="wKioL1iqvWiB5D26AABnMv4XxKI850.png-wh_50" />

650) this.width=650;" src="https://s2.51cto.com/wyfs02/M01/8D/C8/wKioL1iqvYGBLPxKAABnuSk-gXU345.png-wh_500x0-wm_3-wmp_4-s_3908889466.png" title="QQ20170220175644.png" alt="wKioL1iqvYGBLPxKAABnuSk-gXU345.png-wh_50" />

本文出自 “素顏” 部落格,請務必保留此出處http://suyanzhu.blog.51cto.com/8050189/1899587

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.