Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets only imported in resource routes not included in build output #3414

Closed
wKovacs64 opened this issue Jun 8, 2022 · 13 comments · Fixed by #3817 or #3841
Closed

Assets only imported in resource routes not included in build output #3414

wKovacs64 opened this issue Jun 8, 2022 · 13 comments · Fixed by #3817 or #3841
Labels
bug Something isn't working package:dev

Comments

@wKovacs64
Copy link
Contributor

What version of Remix are you using?

1.5.1

Steps to Reproduce

  1. Create a resource route
  2. Import an asset (e.g., an image)
  3. Observe the resulting URL appears correct (includes a hash) 👍
  4. Observe the resulting URL 404s as the asset does not make it into the build directory ☹️

Bonus steps:

  1. Import the asset into a UI route
  2. Observe the asset is now included in the build output

Expected Behavior

I would expect an asset imported (only) in a resource route to be included in the build output.

Actual Behavior

The asset is not included in the build output unless it is also imported in a UI route.

@magnusdr
Copy link

I can reproduce this in my project. My current workaround is to put these images in public/ 🤷‍♂️

@wKovacs64
Copy link
Contributor Author

I can reproduce this in my project. My current workaround is to put these images in public/ 🤷‍♂️

Unfortunately, that approach doesn't benefit from fingerprinting (no hash for cache-busting), if I understand you correctly. My current workaround is to import them (again) in a UI route. 😕

@mcansh mcansh linked a pull request Jul 21, 2022 that will close this issue
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-916caa6-20220726 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@Xiphe
Copy link

Xiphe commented Aug 25, 2022

Gave v0.0.0-nightly-916caa6-20220726 a shot but the problem seems to persist.

We can work around this by also importing the assets from within our client bundle.

// entry.client.tsx
import { hydrate } from 'react-dom';
import { RemixBrowser } from 'remix';

/* requires are not tree shaken so the imports in that file are considered relevant for the frontend */
require('./routes/my-resouce-route[.]css');

hydrate(<RemixBrowser />, document);

When you have server only code in the resource route you want to be more considerate than this, but you get the idea.

@mcansh
Copy link
Collaborator

mcansh commented Aug 25, 2022

Gave v0.0.0-nightly-916caa6-20220726 a shot but the problem seems to persist.

yeah, the solution is that of #3841

@Xiphe
Copy link

Xiphe commented Aug 25, 2022

Cool no prob! Thanks for working on this 👍

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-b1b3759-20220928 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@drochag
Copy link

drochag commented Sep 28, 2022

Worked like a charm, thank you so much !

@wKovacs64
Copy link
Contributor Author

Agreed, that seems to have done it. 👍

@machour
Copy link
Collaborator

machour commented Oct 20, 2022

Fixed in 1.7.3 🎉

@manzano78
Copy link
Contributor

manzano78 commented Oct 31, 2023

@pcattori, FYI this issue reoccurs when we use the unstable vite plugin :) I could reproduce it in one of the latest nightly releases.

@pcattori
Copy link
Contributor

@manzano78 since this issue tracks the bug for the existing compiler, could you open up a separate issue (maybe linking to this one)?

@manzano78
Copy link
Contributor

Sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package:dev
Projects
None yet
8 participants