You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR on new projects, on windows (maybe the issue), the paths generated by webpacker inline and webpacker-dev-server / webpacker binaries are not equal and thus, no files can be found.
Edit: The correct manifest file lives at http://localhost:3000//packs/* (note the double slash).
Everything used to work, but when starting a new project / updating an old working project, a few things are happening:
rails new with webpacker (6.0.3)
everything installs correctly
add the javascript pack in application.html layout
the assets do no precompile, it complains about the compile flag not being true (it is, in the config)
Naturally, the other way to go about this is to start webpack-dev-server, which I do. Same as that issue, no files in packs folder, other than manifest.json. The previous explanation is that it compiles in memory (did it always do this??).
Now, the page loads, BUT the asset can not be found:
Cannot GET /packs/js/application-0b5e9ec7c42a81ea2190.js
So I did a check:
Does that file exist on disk? No
Is that file in the logs? Yes
Does this file exist on http://localhost:3000/<path>? No
Does this file exist on http://localhost:3005/<path>? No
Does the file in the webpack-dev-server manifest exist on disk? No
Is that file in the logs? No
Does this file exist on http://localhost:3000/<path>? Yes
Does this file exist on http://localhost:3005/<path>? Yes
EDIT: The story continues.
For funsies, let's add an extra slash: http://localhost:3000//packs/manifest.json
Does this file match the content in the logs? Yes
Do any of those entries exist? No
Reproduce
Be on Windows 10
Ruby 2.6
Create a new rails project with webpacker (with or without react, doesn't matter)
# Update config/routes.rbRails.application.routes.drawdo# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html#rootto: 'home#show'end
# Updateapp/javascript/packs/application.js// This file is automatically compiled by Webpack, along with any other files// present in this directory. You're encouraged to place your actual application logic in// a relevant structure within app/javascript and only use these pack files to reference// that code so it'll be compiled.import"../stylesheets/application.css"require("@rails/ujs").start()require("turbolinks").start()require("@rails/activestorage").start()require("channels")// Uncomment to copy all static images under ../images to the output folder and reference// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)// or the `imagePath` JavaScript helper below.//// const images = require.context('../images', true)// const imagePath = (name) => images(name, true)
It will complain that the manifest doesn't exist, despite compile: true being set.
Start webpack-dev-server
Refresh. It will load but the files will not be found
Check logs and see the correctly expected paths
Check public/packs/manifest.json on disk and see the same correctly expected paths
Go to http://localhost:3005/manifest.json and see the incorrect paths
Check that a file from the incorrect paths exists on http://localhost:3000/<path>
The text was updated successfully, but these errors were encountered:
SleeplessByte
changed the title
webpack-dev-server manifest paths are incorrect
webpack-dev-server manifest paths are incorrect (on windows)
Aug 2, 2020
I went ahead and just purged gems, yarn cache and everything and it started working again.
No clue what caused this, but it's fixed for me for now. I'll leave this issue for whomever stumbles into this. Shitty solution (because it doesn't tell anyone what the issue was), but "works".
I am also having this issue (or something similar). I have images under images/ and also under images/icons. Somehow, the paths for stuff in /images/icons are being mapped to just icons, but ones inside images map correctly to images. The compilation goes fine, but when I try to visit the page in Rails it can't find the corresponding image because it's looking for it in images/icons. I have tried removing and reinstalling webpacker and also removing and reinstalling all node_modules to no avail.
TL;DR on new projects, on windows (maybe the issue), the paths generated by webpacker inline and webpacker-dev-server / webpacker binaries are not equal and thus, no files can be found.
Edit: The correct manifest file lives at
http://localhost:3000//packs/*
(note the double slash).Description
I actually think this is the same issue as #2512.
Everything used to work, but when starting a new project / updating an old working project, a few things are happening:
rails new
with webpacker (6.0.3)application.html
layoutcompile
flag not being true (it is, in the config)Naturally, the other way to go about this is to start
webpack-dev-server
, which I do. Same as that issue, no files inpacks
folder, other thanmanifest.json
. The previous explanation is that it compiles in memory (did it always do this??).Now, the page loads, BUT the asset can not be found:
So I did a check:
http://localhost:3000/<path>
? Nohttp://localhost:3005/<path>
? NoBut when I checked out the actual
manifest.json
from the webpack-dev-server and compared it with the one generated by rails, they are not the same.http://localhost:3035/manifest.json
http://localhost:3000/packs/manifest.json
So, let's check again
http://localhost:3000/<path>
? Yeshttp://localhost:3005/<path>
? YesEDIT: The story continues.
For funsies, let's add an extra slash:
http://localhost:3000//packs/manifest.json
Reproduce
Now run
rails s
.compile: true
being set.webpack-dev-server
public/packs/manifest.json
on disk and see the same correctly expected pathshttp://localhost:3005/manifest.json
and see the incorrect pathshttp://localhost:3000/<path>
The text was updated successfully, but these errors were encountered: