From 1391c79c2c211f2186d63be3cba8c6f900e5bc0c Mon Sep 17 00:00:00 2001 From: FairyEver <1711467488@qq.com> Date: Thu, 12 Dec 2019 21:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: aa432c5d76488b4784261eea38beeb9b6bb7719e Former-commit-id: e837797eb7ed2a0f48c137714391bc007ecd4d01 Former-commit-id: aeb14aa1316e89fa452a959ae1165c24470c7880 Former-commit-id: 1b1d0641e8e66a3be803fc536ebbad40fe4fdfaf [formerly 2407d26598c1bab4d59de92339dab897f66d3691] Former-commit-id: e05e29af878a2660b6655dcb0a055c1cefdee549 Former-commit-id: d975725cbaf4b9db68011bb1852aa5650b361f3a Former-commit-id: a86a88e58e2fbc8e7a0b80858a18ddce13b7b75d Former-commit-id: 1e787ca9c56244c030346fe80c8cdf008c6040b6 Former-commit-id: e08db44984fd59afbfd3af7336f44dc202752ee3 --- .eslintrc.js | 4 +- package-lock.json.REMOVED.git-id | 2 +- package.json | 2 - vue.config.js | 89 -------------------------------- 4 files changed, 3 insertions(+), 94 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 343a7d43..98d04316 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,8 +8,8 @@ module.exports = { '@vue/standard' ], rules: { - 'no-console': 'off', - 'no-debugger': 'off' + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' }, parserOptions: { parser: 'babel-eslint' diff --git a/package-lock.json.REMOVED.git-id b/package-lock.json.REMOVED.git-id index 37f1b340..9f57a3ba 100644 --- a/package-lock.json.REMOVED.git-id +++ b/package-lock.json.REMOVED.git-id @@ -1 +1 @@ -c2732d55dc11af6a140b280f777b787cc42e6599 \ No newline at end of file +975a87cbfa94ae0055fa5dbbf387398b44b8c8f0 \ No newline at end of file diff --git a/package.json b/package.json index a66252c0..bcd7eecb 100644 --- a/package.json +++ b/package.json @@ -64,12 +64,10 @@ "compression-webpack-plugin": "^3.0.1", "eslint": "^5.16.0", "eslint-plugin-vue": "^5.2.2", - "optimize-css-assets-webpack-plugin": "^5.0.3", "sass": "^1.21.0", "sass-loader": "^7.1.0", "svg-sprite-loader": "^4.1.6", "text-loader": "0.0.1", - "uglifyjs-webpack-plugin": "^2.2.0", "vue-cli-plugin-i18n": "^0.6.0", "vue-template-compiler": "^2.6.10", "webpack-theme-color-replacer": "^1.2.15" diff --git a/vue.config.js b/vue.config.js index c8425209..e28e1592 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,8 +1,5 @@ const CompressionWebpackPlugin = require('compression-webpack-plugin') -const UglifyJsPlugin = require('uglifyjs-webpack-plugin') -const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin') - const VueFilenameInjector = require('@d2-projects/vue-filename-injector') const ThemeColorReplacer = require('webpack-theme-color-replacer') @@ -34,92 +31,6 @@ module.exports = { } }, configureWebpack: { - externals: { - 'vue': 'Vue', - 'vue-router': 'VueRouter', - 'vuex': 'Vuex' - }, - // 关闭文件过大提示,利于打包加快速度 - performance: { - hints: 'warning', - // 入口起点的最大体积 - maxEntrypointSize: 50000000, - // 生成文件的最大体积 - maxAssetSize: 30000000, - // 只给出 js 文件的性能提示 - assetFilter: function(assetFilename) { - return assetFilename.endsWith('.js'); - } - }, - // 公共代码抽离和代码分割 - optimization: { - runtimeChunk: 'single', - splitChunks: { - cacheGroups: { - vendors: { - test: /[\\/]node_modules[\\/]/, - name: 'vendors', - minSize: 30000, - minChunks: 1, - chunks: 'initial', - priority: 1 // 设置处理的优先级,数值越大越优先处理 - }, - commons: { - test: /[\\/]src[\\/]common[\\/]/, - name: 'commons', - minSize: 30000, - minChunks: 3, - chunks: 'initial', - priority: -1, - reuseExistingChunk: true // 允许使用已经存在的代码块 - }, - styles: { - name: 'styles', - test: /\.(sa|sc|c)ss$/, - chunks: 'all', - enforce: true - }, - runtimeChunk: { - name: 'manifest' - } - } - }, - minimizer: [ - // 自定义js优化配置,将会覆盖默认配置 - new UglifyJsPlugin({ - exclude: /\.min\.js$/, // 过滤掉以 '.min.js' 结尾的文件,我们认为这个后缀本身就是已经压缩好的代码,没必要进行二次压缩 - cache: true, - parallel: true, // 开启并行压缩,充分利用cpu - sourceMap: false, - extractComments: false, // 移除注释 - uglifyOptions: { - compress: { - unused: true, - drop_console: true, - drop_debugger: true, - pure_funcs: ['console.log'] - }, - output: { - comments: false - }, - warnings: false - } - }), - // 用于优化css文件 - new OptimizeCssAssetsPlugin({ - assetNameRegExp: /\.css$/g, - cssProcessorOptions: { - safe: true, - autoprefixer: { disable: true }, - mergeLonghand: false, - discardComments: { - removeAll: true // 移除注释 - } - }, - canPrint: true - }) - ] - }, plugins: [ // gzip new CompressionWebpackPlugin({