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

react_on_rails 8.0.0 not generating production builds by default #875

Closed
serodriguez68 opened this issue Jun 14, 2017 · 7 comments
Closed
Labels

Comments

@serodriguez68
Copy link
Contributor

serodriguez68 commented Jun 14, 2017

I upgraded a project I built for learning purposes from react_on_rails version 7 to version 8.0.0 and noticed that when deploying to Heroku, webpack no longer generates a minified production build of React (I can tell because I'm using the react extension for Chrome).

I upgraded using the generator from scratch and moving my code to the newly generated /client folder.

The source code of my project can be found here.

This is also happening with the www.reactrails.com app on version 8.

Is this a bug? or am I missing something in the client/webpack.config.js file?

@justin808
Copy link
Member

justin808 commented Jun 15, 2017

@serodriguez68 Good catch.

Generator

In the case of the generator, we're generating the simplest possible config file, so it's not optimized for production. We should probably use the "-p" option for Webpack (see references below).

https://webpack.js.org/guides/production/#the-automatic-way

The Automatic Way
Running webpack -p (or equivalently webpack --optimize-minimize --define process.env.NODE_ENV="production"). This performs the following steps:

Minification using UglifyJsPlugin
Runs the LoaderOptionsPlugin (see its documentation)
Sets the NodeJS environment variable triggering certain packages to compile differently

reactrails.com

Please report that to the https://github.com/shakacode/react-webpack-rails-tutorial.

@Judahmeek @udovenko @robwise Opinions?

@robwise
Copy link
Contributor

robwise commented Jun 16, 2017

yeah use -p for the production script

shikendon added a commit to denpaio/denpaio that referenced this issue Jun 23, 2017
…rails#875

* Minification using UglifyJsPlugin
* Runs the LoaderOptionsPlugin
* Sets the NodeJS environment variable triggering certain packages to compile differently
@shikendon
Copy link

shikendon commented Jun 23, 2017

And I found the devBuild variable in webpack.config.js always be true because of PR #877. It should be able to generate minified js file correctly after fix that.

@serodriguez68
Copy link
Contributor Author

Ideally the generator should produce a client/package.json file that is ready to go for production builds. I'm not familiar with react_on_rails codebase so I'm not sure where to make the change to make this happen.

Does doing the following change on this file makes the trick?

Change this:

"build:production": "NODE_ENV=production webpack --config webpack.config.js",

For this:

"build:production": "NODE_ENV=production webpack -p --config webpack.config.js",

@justin808
Copy link
Member

@serodriguez68 💯

Please submit a PR and I'll merge it!

Even better if there's a unit test!

Also, please see https://github.com/shakacode/react_on_rails/blob/master/CONTRIBUTING.md for some basic PR hygiene like updating the https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md

@justin808 justin808 added bug and removed enhancement labels Jul 10, 2017
@serodriguez68
Copy link
Contributor Author

serodriguez68 commented Jul 12, 2017

Ok I just submitted PR 895 that fixes that.

@justin808
Copy link
Member

Fixed in #895.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants