semantic-ui-react webpack size is 1.74M? -


i find common vendor project big.

i'm tring see module responsible big size, , found semantic-ui-react taking 1.74m itself.

react-vendor.js 1.74 mb 2 [emitted] [big] react-vendor

'react-vendor': [    'semantic-ui-react',  ],    new commonschunkplugin({     name: "react-vendor",     filename: "react-vendor.js",     minchunks: infinity,   }), 

is there make file size smaller?

step 1

by default, importing library import every component. if using webpack 1, can follow directions shown here in usage section bundlers:

http://react.semantic-ui.com/usage#bundlers

the example configuration shows how can use babel-plugin-lodash (despite name) automatically transform import statements individual component imports. explicitly importing individual components ensure bundling components using. unused components not included in bundle.

step 2

every component includes proptypes definition. these useful in development. quite large , verbose. wrap our prop type definitions automatically removed during minification dead code elimination, provided process.env.node_env set "production" , exposed global.

you should doing required react bundle in production mode. in case, here instructions on how this: how turn on/off reactjs 'development mode'?

removing prop type definitions save additional space.

step 3

with source code cut down include components using, , components cut down production code only, should minify , compress bundle.

check webpack docs enabling production minified code , use dead code elimination, straightforward. can compress bundle with: https://github.com/webpack-contrib/compression-webpack-plugin.

conclusion

there have been updates library since did this, achieved 81.8 kb entire library in umd format, has larger overhead.

pr here showing full setup: https://github.com/webpack-contrib/compression-webpack-plugin

stats here: https://github.com/semantic-org/semantic-ui-react/blob/3aa72bc76aac05c526e2b14a6ed4687995cd11af/stats-library.md


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -