From 7e2d4ed67c94f4cbba389c4004c2b261146d5c74 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 28 Jan 2022 15:57:09 +0800 Subject: [PATCH] optimized output file size --- package.json | 5 ++-- src/layouts/index.ts | 2 ++ vue.config.js | 22 +++++++++++---- yarn.lock | 65 ++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 85 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 1825059156e97..39077f0d5fdb8 100644 --- a/package.json +++ b/package.json @@ -98,9 +98,10 @@ "sass-loader": "^10.1.0", "scss-loader": "^0.0.1", "ts-morph": "^12.0.0", - "typescript": "^4.5.3" + "typescript": "^4.5.3", + "webpack-bundle-analyzer": "^4.5.0" }, - "main": "dist/crawlab-ui.umd.js", + "main": "dist/crawlab-ui.umd.min.js", "files": [ "dist", "public", diff --git a/src/layouts/index.ts b/src/layouts/index.ts index baf0e642f1b2f..aaa97c31127aa 100644 --- a/src/layouts/index.ts +++ b/src/layouts/index.ts @@ -5,6 +5,7 @@ import Sidebar from './components/Sidebar.vue'; import TabsView from './components/TabsView.vue'; import DetailLayout from './content/detail/DetailLayout.vue'; import ListLayout from './content/list/ListLayout.vue'; +import SimpleLayout from './content/simple/SimpleLayout.vue'; export { BlankLayout as ClBlankLayout, @@ -14,4 +15,5 @@ export { TabsView as ClTabsView, DetailLayout as ClDetailLayout, ListLayout as ClListLayout, + SimpleLayout as ClSimpleLayout, }; diff --git a/vue.config.js b/vue.config.js index 3f77fb18b5215..eb2a5272d019a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -75,10 +75,20 @@ if (process.env.ENTRY) { } } -if (['development', 'local'].includes(process.env.NODE_ENV)) { - config.configureWebpack.optimization = optimization -} else if (['production'].includes(process.env.NODE_ENV)) { - // config.configureWebpack.optimization = optimization // TODO: temporarily comment out this line +if (['production'].includes(process.env.NODE_ENV)) { + // config.configureWebpack.optimization = optimization // TODO: need to figure out how to optimize output file size + config.configureWebpack.externals = { + '@fortawesome/fontawesome-svg-core': '@fortawesome/fontawesome-svg-core', + '@fortawesome/free-brands-svg-icons': '@fortawesome/free-brands-svg-icons', + '@fortawesome/free-regular-svg-icons': '@fortawesome/free-regular-svg-icons', + '@fortawesome/free-solid-svg-icons': '@fortawesome/free-solid-svg-icons', + '@element-plus/icons': '@element-plus/icons', + 'atom-material-icons': 'atom-material-icons', + 'codemirror': 'codemirror', + 'fontawesome': 'fontawesome', + 'echarts': 'echarts', + 'element-plus': 'element-plus', + } config.configureWebpack.plugins.push(new CopyWebpackPlugin({ patterns: [ { @@ -88,7 +98,9 @@ if (['development', 'local'].includes(process.env.NODE_ENV)) { })) } else if (['analyze'].includes(process.env.NODE_ENV)) { config.configureWebpack.optimization = optimization - config.configureWebpack.plugins.push(new BundleAnalyzerPlugin()) + config.configureWebpack.plugins.push(new BundleAnalyzerPlugin({ + analyzerPort: 8889, + })) } diff --git a/yarn.lock b/yarn.lock index 7f29f123e192f..d754ee87d60a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1161,6 +1161,11 @@ resolved "https://registry.npm.taobao.org/@polka/url/download/@polka/url-0.5.0.tgz#b21510597fd601e5d7c95008b76bf0d254ebfd31" integrity sha1-shUQWX/WAeXXyVAIt2vw0lTr/TE= +"@polka/url@^1.0.0-next.20": + version "1.0.0-next.21" + resolved "https://registry.npmmirror.com/@polka/url/download/@polka/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1" + integrity sha1-XeWiOFo1MJQn9gEZkrVEUU1VmqE= + "@polka/url@^1.0.0-next.9": version "1.0.0-next.11" resolved "https://registry.npm.taobao.org/@polka/url/download/@polka/url-1.0.0-next.11.tgz#aeb16f50649a91af79dbe36574b66d0f9e4d9f71" @@ -2218,6 +2223,11 @@ acorn-walk@^7.1.1: resolved "https://registry.npm.taobao.org/acorn-walk/download/acorn-walk-7.2.0.tgz?cache=0&sync_timestamp=1597235826369&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Facorn-walk%2Fdownload%2Facorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha1-DeiJpgEgOQmw++B7iTjcIdLpZ7w= +acorn-walk@^8.0.0: + version "8.2.0" + resolved "https://registry.nlark.com/acorn-walk/download/acorn-walk-8.2.0.tgz?cache=0&sync_timestamp=1630916736002&other_urls=https%3A%2F%2Fregistry.nlark.com%2Facorn-walk%2Fdownload%2Facorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha1-dBIQ8uJCZFRQiFOi9E0KuDt/acE= + acorn@^6.1.1, acorn@^6.4.1: version "6.4.2" resolved "https://registry.npm.taobao.org/acorn/download/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" @@ -2228,6 +2238,11 @@ acorn@^7.1.1, acorn@^7.4.0: resolved "https://registry.npm.taobao.org/acorn/download/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo= +acorn@^8.0.4: + version "8.7.0" + resolved "https://registry.npmmirror.com/acorn/download/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" + integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== + acorn@^8.6.0: version "8.6.0" resolved "https://registry.npmmirror.com/acorn/download/acorn-8.6.0.tgz?cache=0&sync_timestamp=1637225522161&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Facorn%2Fdownload%2Facorn-8.6.0.tgz#e3692ba0eb1a0c83eaa4f37f5fa7368dd7142895" @@ -3434,6 +3449,11 @@ commander@^2.12.1, commander@^2.18.0, commander@^2.20.0: resolved "https://registry.npm.taobao.org/commander/download/commander-2.20.3.tgz?cache=0&sync_timestamp=1605992757495&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcommander%2Fdownload%2Fcommander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha1-/UhehMA+tIgcIHIrpIA16FMa6zM= +commander@^7.2.0: + version "7.2.0" + resolved "https://registry.npmmirror.com/commander/download/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" + integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== + commander@~1.1.1: version "1.1.1" resolved "https://registry.nlark.com/commander/download/commander-1.1.1.tgz?cache=0&sync_timestamp=1622954303803&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fcommander%2Fdownload%2Fcommander-1.1.1.tgz#50d1651868ae60eccff0a2d9f34595376bc6b041" @@ -4254,7 +4274,7 @@ dtype@^2.0.0: resolved "https://registry.npm.taobao.org/dtype/download/dtype-2.0.0.tgz#cd052323ce061444ecd2e8f5748f69a29be28434" integrity sha1-zQUjI84GFETs0uj1dI9popvihDQ= -duplexer@^0.1.1: +duplexer@^0.1.1, duplexer@^0.1.2: version "0.1.2" resolved "https://registry.npm.taobao.org/duplexer/download/duplexer-0.1.2.tgz?cache=0&sync_timestamp=1597220926027&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fduplexer%2Fdownload%2Fduplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" integrity sha1-Or5DrvODX4rgd9E23c4PJ2sEAOY= @@ -5490,6 +5510,13 @@ gzip-size@^5.0.0: duplexer "^0.1.1" pify "^4.0.1" +gzip-size@^6.0.0: + version "6.0.0" + resolved "https://registry.npmmirror.com/gzip-size/download/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462" + integrity sha1-BlNn/VDCOcBnHLy61b4+LusQ5GI= + dependencies: + duplexer "^0.1.2" + handle-thing@^2.0.0: version "2.0.1" resolved "https://registry.npm.taobao.org/handle-thing/download/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" @@ -7162,6 +7189,11 @@ mri@^1.1.0: resolved "https://registry.npm.taobao.org/mri/download/mri-1.1.6.tgz#49952e1044db21dbf90f6cd92bc9c9a777d415a6" integrity sha1-SZUuEETbIdv5D2zZK8nJp3fUFaY= +mrmime@^1.0.0: + version "1.0.0" + resolved "https://registry.npmmirror.com/mrmime/download/mrmime-1.0.0.tgz#14d387f0585a5233d291baba339b063752a2398b" + integrity sha1-FNOH8FhaUjPSkbq6M5sGN1KiOYs= + ms@2.0.0: version "2.0.0" resolved "https://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz?cache=0&sync_timestamp=1607433816745&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -7602,7 +7634,7 @@ open@^6.3.0: dependencies: is-wsl "^1.1.0" -opener@^1.5.1: +opener@^1.5.1, opener@^1.5.2: version "1.5.2" resolved "https://registry.npm.taobao.org/opener/download/opener-1.5.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopener%2Fdownload%2Fopener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" integrity sha1-XTfh81B3udysQwE3InGv3rKhNZg= @@ -9314,6 +9346,15 @@ sirv@^1.0.1, sirv@^1.0.10: mime "^2.3.1" totalist "^1.0.0" +sirv@^1.0.7: + version "1.0.19" + resolved "https://registry.npmmirror.com/sirv/download/sirv-1.0.19.tgz#1d73979b38c7fe91fcba49c85280daa9c2363b49" + integrity sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ== + dependencies: + "@polka/url" "^1.0.0-next.20" + mrmime "^1.0.0" + totalist "^1.0.0" + slash@^1.0.0: version "1.0.0" resolved "https://registry.npm.taobao.org/slash/download/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" @@ -10589,6 +10630,21 @@ webpack-bundle-analyzer@^3.8.0: opener "^1.5.1" ws "^6.0.0" +webpack-bundle-analyzer@^4.5.0: + version "4.5.0" + resolved "https://registry.npmmirror.com/webpack-bundle-analyzer/download/webpack-bundle-analyzer-4.5.0.tgz#1b0eea2947e73528754a6f9af3e91b2b6e0f79d5" + integrity sha512-GUMZlM3SKwS8Z+CKeIFx7CVoHn3dXFcUAjT/dcZQQmfSZGvitPfMob2ipjai7ovFFqPvTqkEZ/leL4O0YOdAYQ== + dependencies: + acorn "^8.0.4" + acorn-walk "^8.0.0" + chalk "^4.1.0" + commander "^7.2.0" + gzip-size "^6.0.0" + lodash "^4.17.20" + opener "^1.5.2" + sirv "^1.0.7" + ws "^7.3.1" + webpack-chain@^6.4.0: version "6.5.1" resolved "https://registry.npm.taobao.org/webpack-chain/download/webpack-chain-6.5.1.tgz#4f27284cbbb637e3c8fbdef43eef588d4d861206" @@ -10795,6 +10851,11 @@ ws@^6.0.0, ws@^6.2.1: dependencies: async-limiter "~1.0.0" +ws@^7.3.1: + version "7.5.6" + resolved "https://registry.npmmirror.com/ws/download/ws-7.5.6.tgz#e59fc509fb15ddfb65487ee9765c5a51dec5fe7b" + integrity sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA== + xtend@^4.0.0, xtend@~4.0.1: version "4.0.2" resolved "https://registry.npm.taobao.org/xtend/download/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"