webpack打包不压缩配置

解决webpack打包后js,css,html压缩问题,影响开发:
修改webpack.prod.conf.js文件中如下配置项:

// HTML压缩工具
const HtmlWebpackPlugin = require('html-webpack-plugin')
// CSS压缩工具
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
// JS压缩工具
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

将minify下的值修改为false
new HtmlWebpackPlugin({
  filename: config.build.index,
  template: 'index.html',
  inject: true,
  minify: {
	removeComments: false, // 改为false
	collapseWhitespace: false, // 改为false
	removeAttributeQuotes: false // 改为false
	// more options:
	// https://github.com/kangax/html-minifier#options-quick-reference
  },
  // necessary to consistently work with multiple chunks via CommonsChunkPlugin
  chunksSortMode: 'dependency'
}),
css 压缩代码,将下面代码注释掉
/* 
new OptimizeCSSPlugin({
  cssProcessorOptions: config.build.productionSourceMap
	? { safe: true, map: { inline: false } }
	: { safe: true }
}),
*/
压缩js代码,将下面代码注释掉
/*
new UglifyJsPlugin({
  uglifyOptions: {
	compress: {
	  warnings: false
	}
  },
  sourceMap: config.build.productionSourceMap,
  parallel: true
}),
*/

你可能感兴趣的:(webpack)