標籤: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入門教程十五