Webpack入門教程十五

來源:互聯網
上載者:User

標籤:webpack入門教程十五

81.在webpack.config.js檔案配置collapseWhitespace項,用於刪除空白字元與分行符號,修改內容如下
var webpack = require(‘webpack‘);var HtmlWebpackPlugin = require(‘html-webpack-plugin‘);module.exports = {entry:  __dirname + "/app/Greeter.js",output: {path: __dirname + "/build",filename: "bundle.js"},devServer:{contentBase:"./public",historyApiFallback:true,inline:true},module:{loaders:[{test:/\.json$/,loader:"json-loader"},{test:/\.js$/,exclude:/node_modules/,loader:‘babel-loader‘},{test:/\.css$/,loader:‘style-loader!css-loader?modules‘}]},plugins:[new webpack.BannerPlugin("copyright suyan"),new HtmlWebpackPlugin({template:__dirname + "/app/index.tmpl.html",title:‘htmlwebpackplugin filename test‘,filename:‘filename.html‘,inject:true,hash:true,minify:{removeComments:true,collapseWhitespace:true}})]}
82.使用webpack命令重新打包

650) this.width=650;" src="https://s4.51cto.com/wyfs02/M02/8D/C2/wKioL1iqgEKQxNJYAABWH8nIr4E289.png-wh_500x0-wm_3-wmp_4-s_2088585616.png" title="82.png" alt="wKioL1iqgEKQxNJYAABWH8nIr4E289.png-wh_50" />

83.查看產生的filename.html頁面,產生內容如下

650) this.width=650;" src="https://s1.51cto.com/wyfs02/M00/8D/C5/wKiom1iqgHqCfYRBAABi66SpfBk126.png-wh_500x0-wm_3-wmp_4-s_1920797452.png" title="83.png" alt="wKiom1iqgHqCfYRBAABi66SpfBk126.png-wh_50" />

說明
產生的filename.html檔案中空格和換行已經被清除


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

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.