Skip to content

Commit f966fce

Browse files
committed
add Webpack Visualizer example
1 parent 93566ba commit f966fce

File tree

5 files changed

+145
-15
lines changed

5 files changed

+145
-15
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
- add package: `yarn add monkey-react-scripts`
99
- add `webpack.monkey.js` file
1010
- edit `package.json` file
11+
- add `webpack-visualizer-plugin`
12+
- add package: `yarn add webpack-visualizer-plugin`
13+
- add `./webpack-helpers/pluginsPatch.js` and use it in `webpack.monkey.js`
14+
- build project: `yarn build`
15+
- check `build/stats.html` file
1116

1217
[monkey-react-scripts]: https://github.com/monkey-patches/monkey-react-scripts

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"monkey-react-scripts": "^0.1.0",
77
"react": "^16.1.1",
88
"react-dom": "^16.1.1",
9-
"react-scripts": "1.0.17"
9+
"react-scripts": "1.0.17",
10+
"webpack-visualizer-plugin": "^0.1.11"
1011
},
1112
"scripts": {
1213
"start": "monkey-react-scripts start",

webpack-helpers/pluginsPatch.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Visualizer = require('webpack-visualizer-plugin');
2+
3+
module.exports.pluginsPatch = function pluginsPatch(webpackConfig, isDevelopment) {
4+
if (!isDevelopment) {
5+
webpackConfig.plugins.push(new Visualizer());
6+
}
7+
};

webpack.monkey.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const {pluginsPatch} = require('./webpack-helpers/pluginsPatch');
2+
13
module.exports = function (webpackConfig, isDevelopment) {
2-
// mutate webpackConfig
4+
pluginsPatch(webpackConfig, isDevelopment)
35
};

yarn.lock

+128-13
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ ast-types-flow@0.0.7:
268268
version "0.0.7"
269269
resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad"
270270

271+
ast-types@0.9.6:
272+
version "0.9.6"
273+
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.6.tgz#102c9e9e9005d3e7e3829bf0c4fa24ee862ee9b9"
274+
271275
async-each@^1.0.0:
272276
version "1.0.1"
273277
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d"
@@ -976,6 +980,10 @@ balanced-match@^1.0.0:
976980
version "1.0.0"
977981
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
978982

983+
base62@^1.1.0:
984+
version "1.2.1"
985+
resolved "https://registry.yarnpkg.com/base62/-/base62-1.2.1.tgz#95a5a22350b0a557f3f081247fc2c398803ecb0c"
986+
979987
base64-js@^1.0.2:
980988
version "1.2.1"
981989
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"
@@ -1443,10 +1451,28 @@ commander@2.11.x, commander@~2.11.0:
14431451
version "2.11.0"
14441452
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"
14451453

1454+
commander@^2.5.0:
1455+
version "2.12.1"
1456+
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.1.tgz#468635c4168d06145b9323356d1da84d14ac4a7a"
1457+
14461458
commondir@^1.0.1:
14471459
version "1.0.1"
14481460
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
14491461

1462+
commoner@^0.10.1:
1463+
version "0.10.8"
1464+
resolved "https://registry.yarnpkg.com/commoner/-/commoner-0.10.8.tgz#34fc3672cd24393e8bb47e70caa0293811f4f2c5"
1465+
dependencies:
1466+
commander "^2.5.0"
1467+
detective "^4.3.1"
1468+
glob "^5.0.15"
1469+
graceful-fs "^4.1.2"
1470+
iconv-lite "^0.4.5"
1471+
mkdirp "^0.5.0"
1472+
private "^0.1.6"
1473+
q "^1.1.2"
1474+
recast "^0.11.17"
1475+
14501476
compressible@~2.0.11:
14511477
version "2.0.12"
14521478
resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.12.tgz#c59a5c99db76767e9876500e271ef63b3493bd66"
@@ -1738,6 +1764,10 @@ currently-unhandled@^0.4.1:
17381764
dependencies:
17391765
array-find-index "^1.0.1"
17401766

1767+
d3@^3.5.6:
1768+
version "3.5.17"
1769+
resolved "https://registry.yarnpkg.com/d3/-/d3-3.5.17.tgz#bc46748004378b21a360c9fc7cf5231790762fb8"
1770+
17411771
d@1:
17421772
version "1.0.0"
17431773
resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f"
@@ -1870,6 +1900,13 @@ detect-port-alt@1.1.3:
18701900
address "^1.0.1"
18711901
debug "^2.6.0"
18721902

1903+
detective@^4.3.1:
1904+
version "4.5.0"
1905+
resolved "https://registry.yarnpkg.com/detective/-/detective-4.5.0.tgz#6e5a8c6b26e6c7a254b1c6b6d7490d98ec91edd1"
1906+
dependencies:
1907+
acorn "^4.0.3"
1908+
defined "^1.0.0"
1909+
18731910
diff@^3.2.0:
18741911
version "3.4.0"
18751912
resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c"
@@ -2040,6 +2077,13 @@ entities@~1.1.1:
20402077
version "1.1.1"
20412078
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
20422079

2080+
envify@^3.0.0:
2081+
version "3.4.1"
2082+
resolved "https://registry.yarnpkg.com/envify/-/envify-3.4.1.tgz#d7122329e8df1688ba771b12501917c9ce5cbce8"
2083+
dependencies:
2084+
jstransform "^11.0.3"
2085+
through "~2.3.4"
2086+
20432087
errno@^0.1.3, errno@^0.1.4:
20442088
version "0.1.4"
20452089
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d"
@@ -2280,11 +2324,15 @@ espree@^3.5.1:
22802324
acorn "^5.2.1"
22812325
acorn-jsx "^3.0.0"
22822326

2327+
esprima-fb@^15001.1.0-dev-harmony-fb:
2328+
version "15001.1.0-dev-harmony-fb"
2329+
resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-15001.1.0-dev-harmony-fb.tgz#30a947303c6b8d5e955bee2b99b1d233206a6901"
2330+
22832331
esprima@^2.6.0:
22842332
version "2.7.3"
22852333
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
22862334

2287-
esprima@^3.1.3:
2335+
esprima@^3.1.3, esprima@~3.1.0:
22882336
version "3.1.3"
22892337
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
22902338

@@ -2487,6 +2535,16 @@ fb-watchman@^2.0.0:
24872535
dependencies:
24882536
bser "^2.0.0"
24892537

2538+
fbjs@^0.6.1:
2539+
version "0.6.1"
2540+
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.6.1.tgz#9636b7705f5ba9684d44b72f78321254afc860f7"
2541+
dependencies:
2542+
core-js "^1.0.0"
2543+
loose-envify "^1.0.0"
2544+
promise "^7.0.3"
2545+
ua-parser-js "^0.7.9"
2546+
whatwg-fetch "^0.9.0"
2547+
24902548
fbjs@^0.8.16:
24912549
version "0.8.16"
24922550
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
@@ -2753,6 +2811,16 @@ glob-parent@^2.0.0:
27532811
dependencies:
27542812
is-glob "^2.0.0"
27552813

2814+
glob@^5.0.15:
2815+
version "5.0.15"
2816+
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
2817+
dependencies:
2818+
inflight "^1.0.4"
2819+
inherits "2"
2820+
minimatch "2 || 3"
2821+
once "^1.3.0"
2822+
path-is-absolute "^1.0.0"
2823+
27562824
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
27572825
version "7.1.2"
27582826
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
@@ -3085,7 +3153,7 @@ https-browserify@^1.0.0:
30853153
version "1.0.0"
30863154
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
30873155

3088-
iconv-lite@0.4.19, iconv-lite@^0.4.17, iconv-lite@~0.4.13:
3156+
iconv-lite@0.4.19, iconv-lite@^0.4.17, iconv-lite@^0.4.5, iconv-lite@~0.4.13:
30893157
version "0.4.19"
30903158
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
30913159

@@ -3831,6 +3899,16 @@ jsprim@^1.2.2:
38313899
json-schema "0.2.3"
38323900
verror "1.10.0"
38333901

3902+
jstransform@^11.0.3:
3903+
version "11.0.3"
3904+
resolved "https://registry.yarnpkg.com/jstransform/-/jstransform-11.0.3.tgz#09a78993e0ae4d4ef4487f6155a91f6190cb4223"
3905+
dependencies:
3906+
base62 "^1.1.0"
3907+
commoner "^0.10.1"
3908+
esprima-fb "^15001.1.0-dev-harmony-fb"
3909+
object-assign "^2.0.0"
3910+
source-map "^0.4.2"
3911+
38343912
jsx-ast-utils@^1.4.0:
38353913
version "1.4.1"
38363914
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1"
@@ -4159,18 +4237,18 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:
41594237
version "1.0.1"
41604238
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
41614239

4240+
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
4241+
version "3.0.4"
4242+
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
4243+
dependencies:
4244+
brace-expansion "^1.1.7"
4245+
41624246
minimatch@3.0.3:
41634247
version "3.0.3"
41644248
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
41654249
dependencies:
41664250
brace-expansion "^1.0.0"
41674251

4168-
minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
4169-
version "3.0.4"
4170-
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
4171-
dependencies:
4172-
brace-expansion "^1.1.7"
4173-
41744252
minimist@0.0.8:
41754253
version "0.0.8"
41764254
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
@@ -4386,6 +4464,10 @@ object-assign@4.1.1, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^
43864464
version "4.1.1"
43874465
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
43884466

4467+
object-assign@^2.0.0:
4468+
version "2.1.1"
4469+
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa"
4470+
43894471
object-hash@^1.1.4:
43904472
version "1.2.0"
43914473
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.2.0.tgz#e96af0e96981996a1d47f88ead8f74f1ebc4422b"
@@ -4992,7 +5074,7 @@ pretty-format@^20.0.3:
49925074
ansi-regex "^2.1.1"
49935075
ansi-styles "^3.0.0"
49945076

4995-
private@^0.1.6, private@^0.1.7:
5077+
private@^0.1.6, private@^0.1.7, private@~0.1.5:
49965078
version "0.1.8"
49975079
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
49985080

@@ -5014,7 +5096,7 @@ promise@8.0.1:
50145096
dependencies:
50155097
asap "~2.0.3"
50165098

5017-
promise@^7.1.1:
5099+
promise@^7.0.3, promise@^7.1.1:
50185100
version "7.3.1"
50195101
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
50205102
dependencies:
@@ -5191,6 +5273,10 @@ react-dev-utils@^4.2.1:
51915273
strip-ansi "3.0.1"
51925274
text-table "0.2.0"
51935275

5276+
react-dom@^0.14.0:
5277+
version "0.14.9"
5278+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-0.14.9.tgz#05064a3dcf0fb1880a3b2bfc9d58c55d8d9f6293"
5279+
51945280
react-dom@^16.1.1:
51955281
version "16.1.1"
51965282
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.1.1.tgz#b2e331b6d752faf1a2d31399969399a41d8d45f8"
@@ -5247,6 +5333,13 @@ react-scripts@1.0.17:
52475333
optionalDependencies:
52485334
fsevents "1.1.2"
52495335

5336+
react@^0.14.0:
5337+
version "0.14.9"
5338+
resolved "https://registry.yarnpkg.com/react/-/react-0.14.9.tgz#9110a6497c49d44ba1c0edd317aec29c2e0d91d1"
5339+
dependencies:
5340+
envify "^3.0.0"
5341+
fbjs "^0.6.1"
5342+
52505343
react@^16.1.1:
52515344
version "16.1.1"
52525345
resolved "https://registry.yarnpkg.com/react/-/react-16.1.1.tgz#d5c4ef795507e3012282dd51261ff9c0e824fe1f"
@@ -5323,6 +5416,15 @@ readdirp@^2.0.0:
53235416
readable-stream "^2.0.2"
53245417
set-immediate-shim "^1.0.1"
53255418

5419+
recast@^0.11.17:
5420+
version "0.11.23"
5421+
resolved "https://registry.yarnpkg.com/recast/-/recast-0.11.23.tgz#451fd3004ab1e4df9b4e4b66376b2a21912462d3"
5422+
dependencies:
5423+
ast-types "0.9.6"
5424+
esprima "~3.1.0"
5425+
private "~0.1.5"
5426+
source-map "~0.5.0"
5427+
53265428
recursive-readdir@2.2.1:
53275429
version "2.2.1"
53285430
resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.1.tgz#90ef231d0778c5ce093c9a48d74e5c5422d13a99"
@@ -5796,11 +5898,11 @@ source-map-support@^0.4.15:
57965898
dependencies:
57975899
source-map "^0.5.6"
57985900

5799-
source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1, source-map@~0.5.6:
5901+
source-map@0.5.x, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.6:
58005902
version "0.5.7"
58015903
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
58025904

5803-
source-map@^0.4.4:
5905+
source-map@^0.4.2, source-map@^0.4.4:
58045906
version "0.4.4"
58055907
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
58065908
dependencies:
@@ -6088,7 +6190,7 @@ throat@^3.0.0:
60886190
version "3.2.0"
60896191
resolved "https://registry.yarnpkg.com/throat/-/throat-3.2.0.tgz#50cb0670edbc40237b9e347d7e1f88e4620af836"
60906192

6091-
through@^2.3.6:
6193+
through@^2.3.6, through@~2.3.4:
60926194
version "2.3.8"
60936195
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
60946196

@@ -6450,6 +6552,15 @@ webpack-sources@^1.0.1:
64506552
source-list-map "^2.0.0"
64516553
source-map "~0.6.1"
64526554

6555+
webpack-visualizer-plugin@^0.1.11:
6556+
version "0.1.11"
6557+
resolved "https://registry.yarnpkg.com/webpack-visualizer-plugin/-/webpack-visualizer-plugin-0.1.11.tgz#b8770ad86b4f652612c68b1b782253faf9f8a34e"
6558+
dependencies:
6559+
d3 "^3.5.6"
6560+
mkdirp "^0.5.1"
6561+
react "^0.14.0"
6562+
react-dom "^0.14.0"
6563+
64536564
webpack@3.8.1:
64546565
version "3.8.1"
64556566
resolved "https://registry.yarnpkg.com/webpack/-/webpack-3.8.1.tgz#b16968a81100abe61608b0153c9159ef8bb2bd83"
@@ -6498,6 +6609,10 @@ whatwg-fetch@2.0.3, whatwg-fetch@>=0.10.0:
64986609
version "2.0.3"
64996610
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
65006611

6612+
whatwg-fetch@^0.9.0:
6613+
version "0.9.0"
6614+
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-0.9.0.tgz#0e3684c6cb9995b43efc9df03e4c365d95fd9cc0"
6615+
65016616
whatwg-url@^4.3.0:
65026617
version "4.8.0"
65036618
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.8.0.tgz#d2981aa9148c1e00a41c5a6131166ab4683bbcc0"

0 commit comments

Comments
 (0)