Re: [Rails] rails 6 where to put javascript files

10 views
Skip to first unread message

Ariel Juodziukynas

unread,
Dec 22, 2019, 6:10:58 PM12/22/19
to rubyonra...@googlegroups.com
There's a section specifying where to put js files on the documentation https://github.com/rails/webpacker#paths. You can put the files anywhere, if you put them inside the packs folder webpacker will create bundles using those files, if you put them elsewhere wenpacker will bundle them inside the packs that require them.

El dom., 22 dic. 2019 a las 4:48, fugee ohu (<fuge...@gmail.com>) escribió:
Where do I put my custom javascript files now, under javascripts or under javascripts/packs or should i create a directory like 'custom' under javascripts and then in javascript/packs/application.js i would have to import "../custom" and that would import all the javascript files in the custom directory Can someone please clarify?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8295b70b-e09e-4fe3-96ba-cb5017125ace%40googlegroups.com.

fugee ohu

unread,
Dec 23, 2019, 10:09:29 AM12/23/19
to Ruby on Rails: Talk


On Sunday, December 22, 2019 at 6:10:58 PM UTC-5, Ariel Juodziukynas wrote:
There's a section specifying where to put js files on the documentation https://github.com/rails/webpacker#paths. You can put the files anywhere, if you put them inside the packs folder webpacker will create bundles using those files, if you put them elsewhere wenpacker will bundle them inside the packs that require them.

El dom., 22 dic. 2019 a las 4:48, fugee ohu (<fuge...@gmail.com>) escribió:
Where do I put my custom javascript files now, under javascripts or under javascripts/packs or should i create a directory like 'custom' under javascripts and then in javascript/packs/application.js i would have to import "../custom" and that would import all the javascript files in the custom directory Can someone please clarify?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com.
wenpacker will bundle them inside the packs that require them
What does that mean?

Ariel Juodziukynas

unread,
Dec 23, 2019, 10:45:02 AM12/23/19
to rubyonra...@googlegroups.com
If you have a file inside /packs called application.js that has a line "import Something from '../some_js'", webpacker will include the code from "some_js.js" inside the resulting bundle "application.js".

To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b479f7ff-e3ce-4337-bd94-12042605bc84%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages