From 332f556d1d38d66b3dc7a6717cf8158e0b1d8a9a Mon Sep 17 00:00:00 2001 From: Jesse-Ma <24167796@qq.com> Date: Tue, 29 Nov 2022 17:15:14 +0800 Subject: [PATCH] eslint --- vue.config.js | 61 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/vue.config.js b/vue.config.js index 5705e07..4950b9a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,7 +1,6 @@ const { defineConfig } = require("@vue/cli-service"); const CompressionPlugin = require("compression-webpack-plugin"); const WebpackObfuscator = require('webpack-obfuscator'); -const TerserPlugin = require("terser-webpack-plugin"); module.exports = defineConfig({ @@ -11,37 +10,37 @@ module.exports = defineConfig({ // 为生产环境修改配置 //if (process.env.NODE_ENV === 'production') { - if (true) { - config.plugins.push( - new WebpackObfuscator({ - compact: true,//压缩代码 - controlFlowFlattening: true,//是否启用控制流扁平化(降低1.5倍的运行速度) - controlFlowFlatteningThreshold: 1,//应用概率;在较大的代码库中,建议降低此值,因为大量的控制流转换可能会增加代码的大小并降低代码的速度。 - deadCodeInjection: true,//随机的死代码块(增加了混淆代码的大小) - deadCodeInjectionThreshold: 1,//死代码块的影响概率 - debugProtection: true,//此选项几乎不可能使用开发者工具的控制台选项卡 - disableConsoleOutput: true,//通过用空函数替换它们来禁用console.log,console.info,console.error和console.warn。这使得调试器的使用更加困难。 - identifierNamesGenerator: 'hexadecimal',//标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符) - log: false, - renameGlobals: false,//是否启用全局变量和函数名称的混淆 - rotateStringArray: true,//通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意。 - selfDefending: true,//混淆后的代码,不能使用代码美化,同时需要配置 cpmpat:true; - stringArray: true,//删除字符串文字并将它们放在一个特殊的数组中 - stringArrayThreshold: 1, - transformObjectKeys: true, - unicodeEscapeSequence: false//允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小,并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。 - }, ['static/js/chunk-vendors.*.js']), - new CompressionPlugin({ - algorithm: "gzip", // 使用gzip压缩 - test: /\.js$|\.html$|\.png$|\.jpg$|\.svg$|\.css$/, // 匹配文件名 - filename: "[path][base].gz[query]", // 压缩后的文件名(保持原文件名,后缀加.gz) - minRatio: 1, // 压缩率小于1才会压缩 - threshold: 5120, // 对超过10k的数据压缩 - deleteOriginalAssets: false, // 是否删除未压缩的源文件,谨慎设置,如果希望提供非gzip的资源,可不设置或者设置为false(比如删除打包后的gz后还可以加载到原始资源文件) - }), - ) - } + config.plugins.push( + new WebpackObfuscator({ + compact: true,//压缩代码 + controlFlowFlattening: true,//是否启用控制流扁平化(降低1.5倍的运行速度) + controlFlowFlatteningThreshold: 1,//应用概率;在较大的代码库中,建议降低此值,因为大量的控制流转换可能会增加代码的大小并降低代码的速度。 + deadCodeInjection: true,//随机的死代码块(增加了混淆代码的大小) + deadCodeInjectionThreshold: 1,//死代码块的影响概率 + debugProtection: true,//此选项几乎不可能使用开发者工具的控制台选项卡 + disableConsoleOutput: true,//通过用空函数替换它们来禁用console.log,console.info,console.error和console.warn。这使得调试器的使用更加困难。 + identifierNamesGenerator: 'hexadecimal',//标识符的混淆方式 hexadecimal(十六进制) mangled(短标识符) + log: false, + renameGlobals: false,//是否启用全局变量和函数名称的混淆 + rotateStringArray: true,//通过固定和随机(在代码混淆时生成)的位置移动数组。这使得将删除的字符串的顺序与其原始位置相匹配变得更加困难。如果原始源代码不小,建议使用此选项,因为辅助函数可以引起注意。 + selfDefending: true,//混淆后的代码,不能使用代码美化,同时需要配置 cpmpat:true; + stringArray: true,//删除字符串文字并将它们放在一个特殊的数组中 + stringArrayThreshold: 1, + transformObjectKeys: true, + unicodeEscapeSequence: false//允许启用/禁用字符串转换为unicode转义序列。Unicode转义序列大大增加了代码大小,并且可以轻松地将字符串恢复为原始视图。建议仅对小型源代码启用此选项。 + }, ['static/js/chunk-vendors.*.js']), + + new CompressionPlugin({ + algorithm: "gzip", // 使用gzip压缩 + test: /\.js$|\.html$|\.png$|\.jpg$|\.svg$|\.css$/, // 匹配文件名 + filename: "[path][base].gz[query]", // 压缩后的文件名(保持原文件名,后缀加.gz) + minRatio: 1, // 压缩率小于1才会压缩 + threshold: 5120, // 对超过10k的数据压缩 + deleteOriginalAssets: false, // 是否删除未压缩的源文件,谨慎设置,如果希望提供非gzip的资源,可不设置或者设置为false(比如删除打包后的gz后还可以加载到原始资源文件) + }), + ) + }, transpileDependencies: true, chainWebpack: (config) => {