Closed zeetao closed 5 years ago
Thinking you have to add import statements. This might help https://github.com/tongueroo/jets-example-crud-html/blob/master/app/javascript/packs/application.js
Hmm... am not sure what you mean. I tried adding more directories to the webpacker.yml file for it to compile but it didnt work. The reference at http://rubyonjets.com/docs/assets-serving/ states that I should put images into the app/javascript/images folder, but this does not work. If I put all images into app/javascript/packs, then it does get compiled, but then it converts all my images into .js extensions.....
These paths in webpacker.yml: source_path: app/javascript source_entry_path: packs public_output_path: packs cache_path: tmp/cache/webpacker
I tried the below and it still didn't work source_entry_path: [packs, images] source_entry_path: ['packs', 'images'] source_entry_path: %w[packs images]
I tried importing as you suggested but it looks odd and also didn't work. import '../images/'
What am I doing wrong?
Made some webpacker fixes in the latest release, so first upgrade. Then to import images you actually have to import them explicitly. So this that code won't work 😞
import '../images/'
Something like this will work:
import '../images/path/to/full/image.png'
It’s not great to have to import a large number of image explicitly though. Googled around and it looks like what folks are doing with webpacker is using ERB to loop and import a bunch of files dynamically. Started taking a look at getting webpacker with ERB working but afraid don’t have the time right now. Would be awesome if someone takes a stab at this and would happily take this PR. IMHO, it’s a great way to learn if you want to have a stab at it also. No sweat either way though 👌
Closing this out.
I have javascript, css and font assets placed in app/javascript/packs and images in app/javascript/images, both in several nested folders.
The images do not seem to get compiled. I wonder if I am specifying the path wrong somewhere. Where do I instruct webpack to compile the image assets?
application.rb
Jets.application.configure do config.assets.folders = %w[public] # defaults to public config.assets.max_age = 3600 # when to expire assets end