shakapacker: Webpacker can't find subdir/image.png in manifest.json
This was indeed a bug in webpacker6/shakapacker.
https://github.com/shakacode/shakapacker/issues/44
Webpack not finding image paths after removing the asset pipeline in rails 5.1.7
Webpack needs to be configured to compile your images:
In your app/javascript
directory, create an images folder, and place the logo.png
inside.
image_tag
has been changed to image_pack_tag
now that your images are being compiled with webpack. However, by default you would have to pass in the entire image path each time, beginning with media/
, followed by the path from your webpack source path, which is defined in you webpacker.yml
config file. For example:
<%= image_pack_tag 'media/images/logo.png', alt: 'logo', width: 150%>
To solve this, you can use require.context
:
In your webpage entry point, by default this is located in app/javascript/packs/application.js
, you should add the following line:
const images = require.context("../images", true);
To access the logo image in your view, you can now use:
<%= image_pack_tag 'logo.png', alt: 'logo', width: 150%>
shakapacker: Webpacker can't find subdir/image.png in manifest.json
This was indeed a bug in webpacker6/shakapacker.
https://github.com/shakacode/shakapacker/issues/44
Webpacker can't find application
Thanks for your help. Unfortunately nothing works.
rails assets:clobber
return "error Couldn't find an integrity file" immediately after deleting node_modules folder. (Works after yarn install --check-files).
and rails assets:precompile
return
"C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webpacker-4.0.7/lib/webpacker/webpack_runner.rb:23:in `exec': No such file or directory - C:\Users\[...]\site_test\node_modules\.bin/webpack (Errno::ENOENT)"
but I found what was wrong: the location in my computer!
probably a name problem ...
Rails: Webpacker 4.2 can't find application in /app/public/packs/manifest.json heroku
It looks like there's no application.css
in your manifest.json
which means you might not be importing any css from within your Webpack javascript files.
If that's all true, then you can fix the error in production by one of the following:
- Quick (temporary) fix: Add
extract_css: false
to yourproduction
block inconfig/webpacker.yml
(which would mimic your local environments) - If you don't want to compile css with Webpacker: Remove
<%= stylesheet_pack_tag 'application' %>
from your application layout - If you want to compile some css with Webpacker: Import at least one css file from your Webpack javascript
Rails 6, webpacker: image_pack_tag renders wrong image path, adds assets/ to URI
THE CAUSE:
Just prior to this error I had created a model called 'asset'. Somehow the resources :assets
function in my routes.rb file conflicted with the image_pack_tag
, inserting assets/
in the path for all images. I realized this when I simply commented out the resources :assets
line in my routes.rb file, and all the images loaded properly.
THE SOLUTION:
I namespaced my asset model and also namespaced the resources :assets
line in my routes.rb file. All images load correctly now.
Related Topics
Automatically Precompile Assets Before Pushing to Heroku
How to Pass a Variable to a Layout
Accessing One Controller Variable in Another Controller in Rails
Ruby Mechanize Post with Header
How to Tell or Hint to Rubymine What Type a Local or Instance Variable Is
No Source for Ruby-2.0.0-P451 Provided with Debugger-Ruby_Core_Source Gem
How to Properly Chain Custom Methods in Ruby
Retrieving Image Height with Carrierwave
How to Push Keys and Values into an Empty Hash W/ Ruby
How to Dynamically Call Accessor Methods in Ruby
Where Does Ruby Keep Track of Its Open File Descriptors
How Does Ruby Handle Bytes/Binary
"Gem Update --System Is Disabled on Debian" Error
How to Create a Symbol from a String That Has Whitespaces
In Ruby What Is the Meaning of Colon After Identifier in a Hash