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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/assets/javascripts/components.js
Expand Up @@ -3,7 +3,11 @@

window.React = require('react');
window.ReactDOM = require('react-dom');
window.Perf = require('react-addons-perf');

if (process.env.NODE_ENV !== 'production') {
// perf tracking (aka marks/measures) not needed in production mode
window.Perf = require('react-addons-perf');
}

if (!window.Intl) {
require('intl');
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Expand Up @@ -74,7 +74,7 @@ class Application < Rails::Application
config.middleware.use Rack::Deflater

# babel config can be found in .babelrc
config.browserify_rails.commandline_options = '--transform babelify --extension=".jsx"'
config.browserify_rails.commandline_options = '-t babelify -g [ envify --NODE_ENV ' + ENV['RAILS_ENV'] + ' ] --extension=".jsx"'
config.browserify_rails.evaluate_node_modules = true

config.to_prepare do
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -84,6 +84,7 @@
},
"devDependencies": {
"babel-eslint": "^7.2.2",
"envify": "^4.0.0",
"eslint": "^3.19.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.3"
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Expand Up @@ -2396,6 +2396,13 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"

envify@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/envify/-/envify-4.0.0.tgz#f791343e3d11cc29cce41150300a8af61c66cab0"
dependencies:
esprima "~3.1.0"
through "~2.3.4"

enzyme@^2.8.2:
version "2.8.2"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-2.8.2.tgz#6c8bcb05012abc4aa4bc3213fb23780b9b5b1714"
Expand Down Expand Up @@ -6231,7 +6238,7 @@ through2@^2.0.0:
readable-stream "~2.0.0"
xtend "~4.0.0"

through@2, "through@>=2.2.7 <3", through@^2.3.6:
through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3.4:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"

Expand Down