Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails pre-compile dying on 3MB react file

We are using React on Rails within our Rails app. When we deploy, asset pre-compilation takes ~20 minutes.

Based on the deploy logs, it appears as though most of this time is spent pre-compiling a 3.3MB javascript file. That file "app.js" concatenates two files which are generated by webpack:

# app.js

//= require vendor-bundle (250KB)
//= require app-bundle  (3.3MB)

Should we just come to expect long pre-compile times given the size of app-bundle? Or, can we improve things?

As an additional note, we tried directly compiling app-bundle, instead of requiring it through app.js, and it took the same amount of time.

UPDATE:

We ended up breaking out the client code into a separate create-react-app project, which connects to our Rails app via API. The complexity of our devops and deployment pipeline was greatly reduced -- short of really digging into this error.

like image 385
Ben Avatar asked Apr 07 '18 20:04

Ben


1 Answers

You should definitely integrate webpack using the webpacker gem (https://github.com/rails/webpacker)

You can also try and check Bootsnap gem of Shopify (https://github.com/Shopify/bootsnap)

like image 83
obenda Avatar answered Oct 18 '22 11:10

obenda