Skip to content

Question about folder setup and entry files (packs) when using webpacker #855

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
1 of 4 tasks
karimalmur opened this issue Dec 26, 2017 · 2 comments
Closed
1 of 4 tasks

Comments

@karimalmur
Copy link

Help us help you! Please choose one:

  • My app crashes with react-rails, so I've included the stack trace and the exact steps which make it crash.
  • My app doesn't crash, but I'm getting unexpected behavior. So, I've described the unexpected behavior and suggested a new behavior.
  • I'm trying to use react-rails with another library, but I'm having trouble. I've described my JavaScript management setup (eg, Sprockets, Webpack...), how I'm trying to use this other library, and why it's not working.
  • I have another issue to discuss.

I'm using react-rails with webpacker. My javascripts directory looks like this:

components:
-->posts:
---->posts_show.jsx
     posts_new.jsx

-->users:
---->users_show.jsx

-->shared:
---->alert.jsx
...........

I'm just a little confused about how my packs should look like. Right now I have just one "packs/application.js", which has the code that sets the context for react-rails. I'm calling <%= javascript_pack_tag 'application' %> inside application.html.erb and everything works fine.

But does this mean that every thing under javascript/components gets included for every view?
Should there be a separate pack for each view?
And if that's the case, how do I handle the components that are shared between views (under components/shared)

Thanks

@BookOfGreg
Copy link
Member

I will probably add a small how-to and an example to the react-example-app repo of code splitting.

There are quite a few articles on the subject and although I don't have an example of it interacting with this gem, I'm confident that it should work as we are just using Webpacker directly, the only problem that could happen is if the gem gets upset about the webpacker context serverside, in which case I'd consider that a bug.

https://hackernoon.com/straightforward-code-splitting-with-react-and-webpack-4b94c28f6c3f
https://webpack.js.org/plugins/commons-chunk-plugin/
rails/webpacker#65

Let me know how you get on! If it works then I'd love to see an example, if not then a bug report would help others trying to do this 😄 Good luck! And happy new year :)

@karimalmur
Copy link
Author

Thanks a lot @BookOfGreg
I'll make sure to take a look at the articles you linked.
I also found a similar issue.
Will report back if I made any progress. I just need to decide if I really need code chunking or not.
Thanks for the help! And happy new year to you too.

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