Unlike you young lords, we’re doing our best just to stay alive

preface

1. Introduction

The options options

UglifyOptions compressors

{// Do not display warning message warnings: false, compress: {// Remove debugger drop_debugger: true, // Remove console.* drop_console: True, // Remove reference to console.log // for example, log = console.log, remove log, and remove console.log pure_funcs: ['console.log']}}Copy the code

The parallel multi-process

// Use multiple processes to compress parallel: trueCopy the code

Cache cache

// 使用缓存
cache:true
Copy the code

ExtractComments annotation

// Leave comments // Extract a separate file [name].[hash].[ext].LICENSE extractComments: trueCopy the code

use

The installation

npm i uglifyjs-webpack-plugin -D
Copy the code

configuration

config .plugin('uglifyJs') .use(UglifyJsPlugin, [ { uglifyOptions: { warnings: false, compress: Drop_debugger: true, // Remove console.* function drop_console: True, // Remove a reference to console.log // for example, log = console.log, remove log, and remove console.log pure_funcs: ['console.log']}}, // Parallel run parallel: true, // Enable cache: true, // extractComments: true}])Copy the code

3. Pay attention to

1. The dev environment retains console, but the PROd environment does not have console. 2

The end of the

There were times today when I almost thought I met you and missed you

Good night ^_^

Refer to the link

  • uglifyjs-webpack-plugin npm
  • Uglifyjs-webpack-plugin
  • Uglifyjs configuration items

Review past

  • Learn a Vue plugin (1) every day — Better scroll
  • Learn a VUE plugin (2) every day — vue-awesome-swiper
  • Learn a vUE plugin every day (3) — esLint + prettier + stylelint
  • Learn a VUE plugin (4) every day — the V-Viewer
  • Learn a vUE plugin (5) every day — PostCSs-pxtorem
  • Learn a Vue plugin every day (6) — Momentjs
  • Learn a Vue plugin (7) every day — HammerJS
  • Learn a vUE plugin (8) — McAnvas every day
  • Learn a VUE plugin (9) — MathJax every day
  • Learn a vUE plugin every day (10) — VUe-aPlayer
  • Learn a vUE plugin every day (11) — vue-drag-resize
  • Learn a vUE plugin every day (12) — VUe-fullPage
  • Learn a vUE plugin (13) every day — HTML2Canvas
  • Learn a VUE plug-in (14) every day — vue-pull-to
  • So, how about a VUE plugin (15) every day — Vue-Content-Placeholder
  • Learn a vUE plugin every day (16) – VUe-video-player
  • Learn a vue plugin every day (17) — js-file-download
  • Learn a VUE plugin (18) every day — JS-Audio-Recorder
  • Learn a VUE plugin (19) every day – VUe-TreesELECT
  • Learn a VUE plug-in (20) — ProgressBar every day
  • Learn a VUE plugin every day (21) – ProvidePlugin
  • Learn a VUE plugin (22) every day — VUe-Router
  • Learn a VUE plugin (22) every day — VUe-Router
  • Learn a vue plugin every day (23) – urL-loader
  • Learn a vue plugin (24) every day – DriveJS
  • Learn a vue plugin (25) every day — vuex-Persist