优化代码
This commit is contained in:
@@ -4,7 +4,7 @@ require('./check-versions')()
|
||||
process.env.NODE_ENV = 'production'
|
||||
|
||||
const ora = require('ora')
|
||||
const rm = require('rimraf')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const chalk = require('chalk')
|
||||
const webpack = require('webpack')
|
||||
@@ -14,7 +14,7 @@ const webpackConfig = require('./webpack.prod.conf')
|
||||
const spinner = ora('building for production...')
|
||||
spinner.start()
|
||||
|
||||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
||||
fs.rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), { recursive: true, force: true }, err => {
|
||||
if (err) throw err
|
||||
webpack(webpackConfig, (err, stats) => {
|
||||
spinner.stop()
|
||||
|
||||
@@ -33,15 +33,21 @@ const webpackConfig = merge(baseWebpackConfig, {
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': env
|
||||
}),
|
||||
new UglifyJsPlugin({
|
||||
uglifyOptions: {
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
},
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
parallel: true
|
||||
}),
|
||||
// new UglifyJsPlugin({
|
||||
// uglifyOptions: {
|
||||
// compress: {
|
||||
// warnings: false,
|
||||
// drop_console: true,
|
||||
// pure_funcs: ['console.log']
|
||||
// },
|
||||
// mangle: false,
|
||||
// output: {
|
||||
// beautify: true
|
||||
// }
|
||||
// },
|
||||
// sourceMap: config.build.productionSourceMap,
|
||||
// parallel: true
|
||||
// }),
|
||||
// extract css into its own file
|
||||
new ExtractTextPlugin({
|
||||
filename: utils.assetsPath('css/[name].css?v=' + version), // css/[name].[contenthash].css
|
||||
|
||||
Reference in New Issue
Block a user