Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use envify + NODE_ENV=production for smaller JS bundle #2635

Closed
wants to merge 2 commits into from

Conversation

nolanlawson
Copy link
Contributor

This uses envify as a global Browserify transform to replace usages of process.env.NODE_ENV with "production" when RAILS_ENV is also set to "production", which allows Uglify to remove non-essential code. It also makes it so react-addons-perf is omitted in production mode, since it's not worthwhile in production (it just instruments performance.mark/performance.measures in React's APIs).

Before this PR, application.js is 2.96 MB (2963246 bytes to be exact, 514 kB gzipped). After, it's 2.95 MB (2952387 bytes to be exact, 512 kB gzipped).

@nolanlawson
Copy link
Contributor Author

Just double-checked, and this also correctly uses --NODE_ENV development when running in dev mode (e.g. rails s).

@Wonderfall
Copy link
Contributor

Shouldn't envify be also added to Dependecies in package.json?

@nolanlawson
Copy link
Contributor Author

Yes, I added it to the devDependencies.

@Wonderfall
Copy link
Contributor

Wonderfall commented Apr 30, 2017

Yes but it fails (module can't be found) when NODE_ENV is set to production.

@nolanlawson
Copy link
Contributor Author

nolanlawson commented Apr 30, 2017

What do you mean "it fails"? In this PR I'm not even setting NODE_ENV; I'm just explicitly passing it to envify which achieves the same thing. Note you need to do a yarn install to get the new envify dependency.

@nolanlawson
Copy link
Contributor Author

Ah wait, I forgot to update yarn.lock. Will fix.

@nolanlawson
Copy link
Contributor Author

Note that #2617 would make this PR obsolete.

@Gargron
Copy link
Member

Gargron commented May 3, 2017

As foretold, obsolete through #2617 :P

@Gargron Gargron closed this May 3, 2017
ClearlyClaire added a commit to ClearlyClaire/mastodon that referenced this pull request Feb 20, 2024
* Further reduce CSS differences with upstream

* Reduce differences in markup and CSS with upstream

* Redo collapsible post notifications

* Reduce CSS differences further

* Reduce differences with upstream regarding `.status` and `.status__wrapper`

* Further reduce differences with upstream

* Reduce differences with upstream in DisplayName
fad0805 pushed a commit to fad0805/daydream.ink that referenced this pull request Feb 26, 2024
* Further reduce CSS differences with upstream

* Reduce differences in markup and CSS with upstream

* Redo collapsible post notifications

* Reduce CSS differences further

* Reduce differences with upstream regarding `.status` and `.status__wrapper`

* Further reduce differences with upstream

* Reduce differences with upstream in DisplayName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants