Skip to content

components.js generated by assets:precompile is not used #212

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

Closed
vegetabill opened this issue Mar 16, 2015 · 4 comments
Closed

components.js generated by assets:precompile is not used #212

vegetabill opened this issue Mar 16, 2015 · 4 comments

Comments

@vegetabill
Copy link
Contributor

In my setup, our production environment does not have any asset-related gems and cannot compile any assets.

When I try to render a component using prerender: true the gem tries to use app.assets to find the components.js file but since production doesn't have the asset pipeline configuration, it just gets the plain file contents, which in my case in ES6 unbrowserified but could be coffee for some people or whatever else.

Is there a simple way to have sprockets fetch it from public/assets? I tried a naive approach and it complained I was trying to retrieve a file outside of the asset load paths.

@rmosolgo
Copy link
Member

I don't know of a built-in way to do it!

You can see the lambda used for getting the JS source code as a string here:

https://github.com/reactjs/react-rails/blob/master/lib/react/rails/railtie.rb#L66-L70

You could accomplish your goal by modifying the config to use ||= instead of = at line 66:

https://github.com/reactjs/react-rails/blob/master/lib/react/rails/railtie.rb#L66

Then you could pass your own app.config.react.components_js lambda that gathers up source code from wherever you keep it.

@vegetabill
Copy link
Contributor Author

Okay I'll work on a PR then. Thanks

vegetabill added a commit to vegetabill/react-rails that referenced this issue Mar 16, 2015
…e is not used:

  allow user to override the components_js lamdba
@vegetabill
Copy link
Contributor Author

PR opened. Let me know if it needs any changes. #213

@rmosolgo
Copy link
Member

This should be fixed in the latest react-rails (it uses the sprockets manifest in production). Hopefully we can get that other PR for SprocketsRenderer worked out!

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

2 participants