From b44740c85b367ea9dbeadffaece0b08f47f32607 Mon Sep 17 00:00:00 2001 From: qishibo Date: Fri, 26 Nov 2021 11:14:04 +0800 Subject: [PATCH] optimize build size --- build/webpack.dev.conf.js | 2 +- build/webpack.prod.conf.js | 24 +++++++++++------------- config/index.js | 4 ++-- src/components/JsonEditor.vue | 3 ++- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 6a5679a..67c0773 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -50,7 +50,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { }, plugins: [ new VueLoaderPlugin(), - new MonacoWebpackPlugin(), + new MonacoWebpackPlugin({languages: ['json'], features: []}), // new webpack.DefinePlugin({ // 'process.env': require('../config/dev.env') // }), diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 580f06d..d685695 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -14,6 +14,7 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const VueLoaderPlugin = require('vue-loader/lib/plugin'); const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); +// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin const env = require('../config/prod.env') @@ -36,8 +37,10 @@ const webpackConfig = merge(baseWebpackConfig, { chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') }, plugins: [ + // show bundle analysis if need + // new BundleAnalyzerPlugin(), new VueLoaderPlugin(), - new MonacoWebpackPlugin({languages: ['json']}), + new MonacoWebpackPlugin({languages: ['json'], features: []}), // http://vuejs.github.io/vue-loader/en/workflow/production.html // new webpack.DefinePlugin({ // 'process.env': env @@ -154,18 +157,13 @@ const webpackConfig = merge(baseWebpackConfig, { ], splitChunks: { chunks: 'all', - cacheGroups: { - // commons: { - // name: 'commons', - // chunks: 'initial', - // minChunks: 2 - // }, - commons: { - test: /[\\/]node_modules[\\/]/, - name: 'vendors', - chunks: 'all', - }, - } + // cacheGroups: { + // commons: { + // test: /[\\/]node_modules[\\/]/, + // name: 'vendors', + // chunks: 'all', + // }, + // } } }, }) diff --git a/config/index.js b/config/index.js index 834ba02..d54acee 100644 --- a/config/index.js +++ b/config/index.js @@ -50,9 +50,9 @@ module.exports = { * Source Maps */ - productionSourceMap: true, + productionSourceMap: false, // https://webpack.js.org/configuration/devtool/#production - devtool: '#source-map', + // devtool: '#source-map', // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. diff --git a/src/components/JsonEditor.vue b/src/components/JsonEditor.vue index 92b0539..d353693 100644 --- a/src/components/JsonEditor.vue +++ b/src/components/JsonEditor.vue @@ -12,7 +12,8 @@