Skip to content

Commit

Permalink
feat: optimize minification
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 24, 2018
1 parent eddc68e commit bd1ffd3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/@vue/cli-service/lib/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ module.exports = (api, options) => {
.add(api.resolve('node_modules'))
.add(resolveLocal('node_modules'))

webpackConfig.module
.noParse(/^(vue|vue-router|vuex|vuex-router-sync)$/)

// js is handled by cli-plugin-bable

webpackConfig.module
Expand Down
31 changes: 31 additions & 0 deletions packages/@vue/cli-service/lib/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,37 @@ module.exports = (api, options) => {
.use(require('uglifyjs-webpack-plugin'), [{
uglifyOptions: {
compress: {
// turn off flags with small gains to speed up minification
arrows: false,
collapse_vars: false, // 0.3kb
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
inline: false,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
switches: false,
toplevel: false,
typeofs: false,

// a few flags with noticable gains/speed ratio
// numbers based on out of the box vendor bundle
booleans: true, // 0.7kb
if_return: true, // 0.4kb
sequences: true, // 0.7kb
unused: true, // 2.3kb

// required features to drop conditional branches
conditionals: true,
dead_code: true,
evaluate: true,

// turn off warnings when dropping dead code
warnings: false
}
},
Expand Down

0 comments on commit bd1ffd3

Please sign in to comment.