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

Minify js in production. #234

Merged
merged 1 commit into from
Feb 27, 2016

Conversation

lukeasrodgers
Copy link
Contributor

The rake asset compilation task will now run the production-specific npm build scripts, which employ the UglifyJsPlugin plugin.

There may be reasons I'm not aware of to not do this, but this is what I would assume would happen for a production build, which is generally what you're targeting when running asset precompilation.

The numbers below just approximately sum vendor and app bundles.

current bin/rake assets:precompile (total approx 6.1 MB)

precompile-current

explicitly running npm prod builds in bin/rake assets:precompile (total approx 2.3 MB)

precompile-current-prod

explicitly running npm prod builds in bin/rake assets:precompile AND adding minification plugin (total approx 600 KB)

precompile-witih-min

Review on Reviewable

@justin808
Copy link
Member

2.3 MB ==> 600K

👏 👏 👏

sh "cd client && npm run build:client"
sh "cd client && npm run build:server"
sh "cd client && npm run build:production:client"
sh "cd client && npm run build:production:server"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GREAT catch!

@lukeasrodgers
Copy link
Contributor Author

I removed the extraneous webpack uglify plugin code, so we're just relying on the rails asset pipeline for now. It sounds like further optimization may be possible, but I think that can be accomplished in other PRs.

EDIT somehow messed up that commit, and only changed the message. The uglify plugin should actually be gone now.

The rake asset compilation task will now run the production-specific
npm build scripts.
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.

3 participants