Browse Source

打包后删除console

yx 4 years ago
parent
commit
6917a48d71
2 changed files with 25 additions and 1 deletions
  1. 2 1
      package.json
  2. 23 0
      vue.config.js

+ 2 - 1
package.json

@@ -8,7 +8,7 @@
     "lint": "vue-cli-service lint"
   },
   "dependencies": {
-   "@saga-web/base": "2.1.27",
+    "@saga-web/base": "2.1.27",
     "@saga-web/big": "1.0.110",
     "@saga-web/draw": "2.1.107",
     "@saga-web/feng-map": "1.0.43",
@@ -45,6 +45,7 @@
     "polybooljs": "^1.2.0",
     "stylus": "^0.54.7",
     "stylus-loader": "^3.0.2",
+    "terser-webpack-plugin": "^4.0.0",
     "typescript": "~3.8.3",
     "vue-svg-loader": "^0.15.0",
     "vue-template-compiler": "^2.6.11"

+ 23 - 0
vue.config.js

@@ -1,4 +1,5 @@
 const CompressionPlugin = require('compression-webpack-plugin')
+const TerserPlugin = require('terser-webpack-plugin')
 module.exports = {
     devServer: {
         port: 8091,
@@ -62,6 +63,28 @@ module.exports = {
     },
     // 配置webpack
     configureWebpack: (config) => {
+        config.optimization = {
+            minimize: true,
+            minimizer: [
+                new TerserPlugin({
+                    terserOptions: {
+                        // ecma: undefined,
+                        // warnings: false,
+                        // parse: {},
+                        compress: { drop_console: true },
+                        // mangle: true, // Note `mangle.properties` is `false` by default.
+                        // module: false,
+                        output: { comments: false },
+                        // toplevel: false,
+                        // nameCache: null,
+                        // ie8: false,
+                        // keep_classnames: undefined,
+                        // keep_fnames: false,
+                        // safari10: false,
+                    },
+                }),
+            ],
+        }
         return {
             plugins: [
                 // 压缩代码