## 安装插件
npm install extract-text-webpack-plugin@next
## webpack中配置插件
const ExtractTextPlugin=require("extract-text-webpack-plugin")
test:/\.css$/,
use:ExtractTextPlugin.extract({
fallback: "vue-style-loader",
use: "css-loader"
})
plugins:[
new ExtractTextPlugin("styles.css"),
],
## 安装插件
npm install uglifyjs-webpack-plugin --save-dev
## webpack中配置
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
plugins:[
new UglifyJsPlugin({
parallel: 4,
uglifyOptions: {
output: {
comments: false,
beautify: false,
},
},
sourceMap:false,
cache: true,
}),]
## 安装插件
npm install compression-webpack-plugin --save-dev
const CompressionPlugin = require('compression-webpack-plugin')
new CompressionPlugin({
// asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(js)$'
),
threshold: 10240,
minRatio: 0.8}),
const webpack = require('webpack');
new webpack.DefinePlugin({
"process.env":{
NODE_ENV:JSON.stringify('production')
}
})