Ivan
Ivan

Reputation: 311

Too big file size of Reactjs application after building via browserify + reactify

I am trying to build my simple Reactjs application via browserify+reactify but see the error in console

Note: The code generator has deoptimised the styling of "http://localhost:8000/app.js" as it exceeds the max of "100KB".

//index.js size 5KB
var React = require('react');
var ReactDOM = require('react-dom');
var CommentList = React.createClass({...});
//terminal
browserify -t reactify index.js > app.js //after that size more than 600KB

Any ideas how to solve it?

Upvotes: 1

Views: 1030

Answers (2)

Isuru Dilhan
Isuru Dilhan

Reputation: 51

In react/redux/webpack/babel build fixed this error by removing script tag type text/babel

<script type="text/babel" src="/js/bundle.js"></script>

Into

<script src="/js/bundle.js"></script>

Upvotes: 3

Guilherme Nagatomo
Guilherme Nagatomo

Reputation: 306

Setting NODE_ENV environment var before running browserify like this:

NODE_ENV=production browserify -t reactify index.js > app.js

If the bundle file size is still too large, consider using uglify:

NODE_ENV=production browserify -t reactify index.js | uglifyjs -c > app.js

Upvotes: 1

Related Questions