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

Possible Simplified Rails Configuration without Asset Pipeline #696

Closed
rupurt opened this issue Jan 27, 2017 · 8 comments
Closed

Possible Simplified Rails Configuration without Asset Pipeline #696

rupurt opened this issue Jan 27, 2017 · 8 comments

Comments

@rupurt
Copy link
Contributor

rupurt commented Jan 27, 2017

Hey react_on_rails team,

Love the work you've put into the gem and I've made great use out of it over the last year ❤️. My Rails and Webpack configurations have evolved since I first installed the gem. I've got it to the point where there is actually very little configuration needed on either side and have extracted the Asset Pipeline/Webpack integration into a bare bones plugin. I thought I'd drop you guys a note to see what you think about this alternate configuration and if you'd be open to possibly changing the way react_on_rails works.

https://github.com/rupurt/webpack-sprockets-rails-manifest-plugin

IMHO the biggest win from the simplified configuration is the ability to use standard Rails view helpers to load Webpack build assets directly and skip the Asset Pipeline while still leveraging all the Webpack goodness such as finger printing, HMR.

<% # app/views/layouts/application.html.erb %>
<% # Use rails helpers in the same way you normally would with sprockets %>
<!DOCTYPE html>
<html lang="en">
  <head></head>
  <body>
    <%= javascript_include_tag "webpack-application-bundle" %>
  </body>
</html>
// client/bundles/webpack-application.js
alert("Howdy, I'm a Javascript file downloaded from public/assets");

I've also extracted a second plugin which helps reduce the friction of requiring Webpack assets within asset pipeline files for legacy apps. https://github.com/rupurt/webpack-copy-after-build-plugin

@justin808
Copy link
Member

I'll check this out over the weekend. In the meantime, any comments on: #671

@rupurt
Copy link
Contributor Author

rupurt commented Jan 27, 2017

@justin808 It seems like it's the exact same idea. https://github.com/rupurt/webpack-sprockets-rails-manifest-plugin#how-does-it-work describes how sprockets-rails can map logical paths to file system paths that end up getting served out of public.

I'll play around with https://github.com/mikechau/sprockets-stats-webpack-plugin and come up with 2 example repos so we can compare & contrast the 2 techniques. If sprockets-stats-webpack-plugin already handles all of this I'm more than happy to abandon my plugin and move forward with sprockets-stats-webpack-plugin

@rupurt
Copy link
Contributor Author

rupurt commented Jan 27, 2017

@justin808 I've added an example app along with the steps required for webpack-sprockets-rails-manifest-plugin. https://github.com/rupurt/react_on_rails_simplified_configuration_examples/tree/master/greenfield

I'll add extra examples for:

Lmk if you have any questions about how it works or if you have trouble getting setup

@justin808
Copy link
Member

@rupurt Fabulous!

@justin808
Copy link
Member

@rupurt Please let me know how this is going!

@justin808 justin808 changed the title Possible Simplified Rails Configuration Possible Simplified Rails Configuration without Asset Pipeline Feb 2, 2017
@rupurt
Copy link
Contributor Author

rupurt commented Feb 3, 2017

@justin808 I added examples for HMR & a contrasting setup for the sprockets-stats-webpack-plugin.

From what I can tell they are very similar.

sprockets-stats-webpack-plugin has support for the integrity hash but has a more complicated setup that doesn't use base webpack config settings.

webpack-sprockets-rails-manifest-plugin doesn't support the integrity hash, but uses standard webpack config settings thus doesn't require much or any extra config.

Lmk what you think and how you want to proceed

@justin808
Copy link
Member

Hi @rupurt! Please see rails/webpacker#139. Very soon, we won't be putting Webpack assets through the rails asset pipeline!

I hope we can work together on this transition!

Maybe take a look at https://github.com/gauravtiwari/webpacker-example-app.

CC: @gauravtiwari.

@justin808
Copy link
Member

This is going to be fixed by the updates to use Webpacker. Any volunteers?

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

No branches or pull requests

2 participants