Asset css leads to 404

Look at this thread- https://discourse.roots.io/t/npm-run-build-production-renames-images-displaying-image-in-theme-file/8263

Same issue happened for my site theme assets. With the help above thread i fixed the image issue that replacing get_template_directory_uri() to App\asset_path.
But css still causing 404.

Any suggestions?
Thanks.

Assuming this is Sage 9, are your devURL and publicPath correct?

Hi Alex,
Thanks for your answer.
PublicPath is correct. But devURL is defined as some other URL… Do i need to replace it with our current dev server URL (Screenshot by Lightshot) or hostname ?

And please confirm shall i edit \resources\assets\config.json file?

Hi Alex,

I just changed devURL and deployed to dev & stage(test) environment.
Still seeing 404. Any suggestions?

I believe your devURL will be the URL you sent a screenshot of. If that’s right and the publicPath is correct (/wp-content/themes/theme-name if you’re not using Bedrock) then I would take a look at:

a. Where is the browser looking for the CSS file – this should be in console.
b. How does that differ from where the CSS file actually is.

Hi Alex,

Yes, i replaced the actual dev URL in config.json and the publisPath is correct. See - Screenshot by Lightshot
Note: I am not facing assets 404 issue in dev, its causing in staging site. Our stage environment URL is - https://prnt.sc/HHnurRO_wEqT, Should i replace staging site URL in config.json ?

a. I checked in browser view page source. But that file is not linked in css
This is the sources from console - https://prnt.sc/FxRg6PcpGpEc

b. Actually the app.css & main.css files are present with some random number in wp-content\themes\theme-name\dist\styles\app_70191d12.css and main_70191d12.css
(Like images)
And app.scss and main.scss files are present in wp-content\themes\theme-name\resources\assets\styles\ folder. In config.json file, there is scss files are linked - https://prnt.sc/mlNLTSvLZBSz

Note: I am seeing the 404 error for .css files not for .scss files - https://prnt.sc/CMT64epQiMm-

Alex,
Regarding the png image fix,
Now the images are displaying in production. but still i am seeing 404 errors for the actual image name. - Screenshot by Lightshot

By clicking the link it is showing 404 page - https://prnt.sc/o0FnmB16HTqJ

Hi @AlexHay

Kindly check my comments and update.

Hi @Hema_B

I’m afraid theres not much more I can personally suggest. If I were you I would spend a bit of time looking into whether the 404’ing assets exist in the directory that the 404 is giving you.

If they do exist then i’d assume it’s a permission issue.

If they don’t exist in that exact directory then find where they are and tweak your config to put them in the right place on build.

1 Like

@Hema_B This is an official warning since you ignored my last post on your previous topic about this same issue. If you choose to create another topic that isn’t in the jobs category to hire someone for this same issue, you will no longer be able to participate on these forums.

1 Like