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

'rake assets:precompile' not functioning properly #30

Open
hhutch opened this issue Jul 28, 2014 · 11 comments
Open

'rake assets:precompile' not functioning properly #30

hhutch opened this issue Jul 28, 2014 · 11 comments

Comments

@hhutch
Copy link

hhutch commented Jul 28, 2014

Steps to reproduce:

  1. default configuration options for browserify-rails
  2. all node modules in ROOT/node_modules with ROOT/package.json
  3. all JSX/React code in ROOT/app/assets/javascripts
  4. App functions properly in develop mode
  5. change config/environments/development.rb to 'config.assets.debug = true'
  6. run
rake assets:precompile RAILS_ENV=development

RESULT:
browserify does not compile into a single JS asset and individual JS files (such as React libraries) are loaded but throw errors

Please let me know if I am making some sort of mistake, but as of now I have to revert to manual compilation as recommended in issue #27

@martenlienen
Copy link
Collaborator

assets:precompile should be run in production environment, so RAILS_ENV=production rake assets:precompile or simply rake assets:precompile, because this task uses the production environment by default, I think.

Does this fix it?

@hhutch
Copy link
Author

hhutch commented Jul 29, 2014

I get the same error running precompiled assets in both production and development modes. I am attempting to deploy to Heroku. Running with browserify-rails in development, not recompiling assets, works well.

I am using both NPM installed node_modules and writing many of my own components for use in a React UI.

@msernatinger
Copy link

Hi. I'm having this very same issue on Rails 3.2.17. What I am observing is that the Rails engine is not being registered when I run rake assets:precompile. It works fine with development-mode runtime asset compilation.

It's also not clear from the Readme which versions of Rails are supported. I would guess at least 3.2 and up?

@michael-ns
Copy link

It works fine when I run RAILS_ENV=production rake assets:precompile on my local.
But it throw the following error message when I push to heroku master:

   Cleaning up the bundler cache. 

-----> Using Node.js version: 0.10.21
-----> Installing JavaScript dependencies using Bower 1.3.9
bower moment#* cached git://github.com/moment/moment.git#2.8.3
bower moment#* validate 2.8.3 against git://github.com/moment/moment.git#*
bower moment#* install moment#2.8.3
moment#2.8.3 bower_components/moment
Cleaning up the bower tmp.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
BrowserifyRails::BrowserifyError: browserify could not be found at /tmp/build_150c72a7-cb5c-425c-99d0-1fdafc780a27/./node_modules/.bin/browserify. Please run npm install.
(in /tmp/build_150c72a7-cb5c-425c-99d0-1fdafc780a27/app/assets/javascripts/components.js)

@ikido
Copy link

ikido commented Jan 27, 2015

I've got same error as michael-ns when pushing to heroku. If I include node-modules folder into the repo I get Errno::EPIPE: Broken pipe error. Any suggestions?

As a workaround you can disable asset compilation for production and sync manually with rake assets:precompile RAILS_ENV=production

@joaovpmamede
Copy link

I'm having the same problem.

Currently doing what @ikido suggested and it works but it's not the ideal.

@chikathreesix
Copy link

I had same issue as @michael-ns and found the solution.
Here is what I did.
http://ryochikazawa.com/2015/01/30/heroku-with-browserify-rails.html

@joaovpmamede
Copy link

@chikathreesix thanks a lot for finding the solution to this.
Anyway, when you write:

Create .buildpack file for the multi-buildpack to make sure node.js is compiled before ruby.

I think the file has to be named .buildpacks instead of .buildpack (http://stackoverflow.com/a/14801582)

@chikathreesix
Copy link

@joaovpmamede thank you for pointing this out.
Yeah, you're correct. I've fixed the blog post.

@kfamilonidis
Copy link

Hello I have the same issue with this output and rails setup https://gist.github.com/kfamilonidis/e21e2b7e088732e684fb
I haven't found any resolution yet other than to manually run.

NODE_VERSION=v5.0.0 RAILS_ENV=production /usr/local/rvm/bin/rvm default do bundle exec rake assets:precompile

=== UPDATE

solved - I replaced the double quotes with single ones on the browserify parameters and worked!

config.browserify_rails.commandline_options = "--transform reactify --extension='.jsx'"

insead of

config.browserify_rails.commandline_options = "--transform reactify --extension=\".jsx\" ".

@hsume2
Copy link
Owner

hsume2 commented Dec 10, 2015

@kfamilonidis It's awesome that you found a fix for this issue, thanks! Active development for browserify-rails has actually moved to https://github.com/browserify-rails/browserify-rails, so it'd be great if you could share your findings there :)

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

No branches or pull requests

9 participants