From d3720ca008dcb920c061c90cb0755e1c5e9299a6 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Mon, 22 Jan 2018 00:02:31 -0500 Subject: [PATCH] refactor: added bundle analyzer --- package.json | 2 ++ poi.config.js | 18 ++++++++++++----- yarn.lock | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 9e874317..3e1399bf 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "stop": "node wiki stop", "restart": "node wiki restart", "build": "poi build", + "build:analyze": "poi build --analyze", "dev:client": "poi watch", "dev:server": "nodemon", "dev:server:alt": "node-dev server --no-deps --respawn --no-notify", @@ -190,6 +191,7 @@ "vue-template-es2015-compiler": "1.6.0", "vuex": "3.0.1", "vuex-persistedstate": "2.4.2", + "webpack-bundle-analyzer": "2.9.2", "whatwg-fetch": "2.0.3" }, "jest": { diff --git a/poi.config.js b/poi.config.js index fa212138..cf1c5662 100644 --- a/poi.config.js +++ b/poi.config.js @@ -1,8 +1,9 @@ const path = require('path') -const _ = require('lodash') -const SpriteLoaderPlugin = require('svg-sprite-loader/plugin') +const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') +// const _ = require('lodash') +// const SpriteLoaderPlugin = require('svg-sprite-loader/plugin') -module.exports = { +module.exports = options => ({ entry: 'client/index.js', dist: 'assets', staticFolder: 'client/static', @@ -27,7 +28,7 @@ module.exports = { }, html: false, hash: false, - sourceMap: true, + sourceMap: false, extendWebpack (config) { // Vue - Default SCSS Imports config.module.rule('vue') @@ -68,8 +69,15 @@ module.exports = { // Vue with Compiler Alias config.resolve.alias.set('vue$', 'vue/dist/vue.common.js') + + // Bundle Analyze + if (options.analyze) { + config.plugin('analyzer').use(BundleAnalyzerPlugin, [{ + analyzerMode: 'static' + }]) + } }, webpack (config) { return config } -} +}) diff --git a/yarn.lock b/yarn.lock index a05327e6..d00323dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -657,6 +657,10 @@ async-foreach@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/async-foreach/-/async-foreach-0.1.3.tgz#36121f845c0578172de419a97dbeb1d16ec34542" +async-limiter@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" + async-listener@^0.6.0: version "0.6.7" resolved "https://registry.yarnpkg.com/async-listener/-/async-listener-0.6.7.tgz#793971ce6f431e41f75cef6c0a1706b9053e4d5b" @@ -3429,7 +3433,7 @@ duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" -duplexer@~0.1.1: +duplexer@^0.1.1, duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" @@ -3476,6 +3480,10 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" +ejs@^2.5.6: + version "2.5.7" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" + electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.30: version "1.3.31" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.31.tgz#00d832cba9fe2358652b0c48a8816c8e3a037e9f" @@ -4016,7 +4024,7 @@ express-session@1.15.6: uid-safe "~2.1.5" utils-merge "1.0.1" -express@4.16.2, express@^4.16.2: +express@4.16.2, express@^4.15.2, express@^4.16.2: version "4.16.2" resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" dependencies: @@ -4291,6 +4299,10 @@ filesize.js@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/filesize.js/-/filesize.js-1.0.2.tgz#934c013395a71804875cf11e6f1ffe211c3f2192" +filesize@^3.5.9: + version "3.5.11" + resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee" + filewatcher@~3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/filewatcher/-/filewatcher-3.0.1.tgz#f4a1957355ddaf443ccd78a895f3d55e23c8a034" @@ -4893,6 +4905,12 @@ growly@^1.2.0, growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" +gzip-size@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520" + dependencies: + duplexer "^0.1.1" + handle-thing@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" @@ -7871,6 +7889,10 @@ opencollective@^1.0.3: node-fetch "1.6.3" opn "4.0.2" +opener@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8" + opn@4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95" @@ -11167,6 +11189,10 @@ ultron@1.0.x: version "1.0.2" resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" +ultron@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" + undefsafe@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-0.0.3.tgz#ecca3a03e56b9af17385baac812ac83b994a962f" @@ -11658,6 +11684,22 @@ webidl-conversions@^4.0.1, webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" +webpack-bundle-analyzer@2.9.2: + version "2.9.2" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.9.2.tgz#63ed86eb71cc4cda86f68e685a84530ba0126449" + dependencies: + acorn "^5.1.1" + chalk "^1.1.3" + commander "^2.9.0" + ejs "^2.5.6" + express "^4.15.2" + filesize "^3.5.9" + gzip-size "^3.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + opener "^1.4.3" + ws "^4.0.0" + webpack-chain@^4.4.2: version "4.5.0" resolved "https://registry.yarnpkg.com/webpack-chain/-/webpack-chain-4.5.0.tgz#390835bca2950f0f62fe3182ab90839ea8f6239d" @@ -11909,6 +11951,14 @@ ws@^1.1.1: options ">=0.0.5" ultron "1.0.x" +ws@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-4.0.0.tgz#bfe1da4c08eeb9780b986e0e4d10eccd7345999f" + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"