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

Remix 1.16 unstable_dev - problems with assets #6271

Closed
1 task done
arekbartnik opened this issue May 2, 2023 · 11 comments
Closed
1 task done

Remix 1.16 unstable_dev - problems with assets #6271

arekbartnik opened this issue May 2, 2023 · 11 comments
Assignees

Comments

@arekbartnik
Copy link

arekbartnik commented May 2, 2023

What version of Remix are you using?

1.16

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

  1. git clone git@github.com:ArekBartnik/remix-116-dev-assets.git
  2. npm i
  3. npm run dev
  4. go to http://localhost:3000

Expected Behavior

It should show a page using Inter font and an icon after "Welcome to Remix".

With unstable_dev: true; Without unstable_dev: true
image image

Without new devserver paths to assets are relative but after turning this flag they change to absolute.

Actual Behavior

There're 2 errors:

image

@mikeybinns
Copy link
Contributor

Just to note I'm also receiving the same "Domains, protocols and ports must match." error, and 404 errors on objects in the public folder (like fonts).

@pcattori
Copy link
Contributor

pcattori commented May 2, 2023

#6279 fixes this issue for non-Remix public assets like fonts. But svgs are trickier since browsers don't like grabbing those from different origins for security reasons. Will keep looking into svg fixes.

#6279 should now fix all asset types

@arekbartnik
Copy link
Author

@pcattori I saw in the merge that SVGs will be inlined and I'm not a fun of this solution. It will inflate HTML and could cause some unexpected behaviour only in "dev" making it harder to debug.

@pcattori
Copy link
Contributor

pcattori commented May 2, 2023

@arekbartnik unfortunately there is no way for <use/> href to participate in CORS.

The alternative would be to proxy everything from our dev server, but that would require rearchitecting parts of the dev server. I'm happy to consider doing that, but that will take longer. In the meantime, inlining via Data URLs does the job.

@arekbartnik
Copy link
Author

@pcattori I would like to understand why it was decided to serve files from a different origin? I think it's could be especially painful because "production" will be different (most assets are relative.)

@pcattori
Copy link
Contributor

pcattori commented May 2, 2023

Its so that HMR updates can safely be sent immediately to the browser without needing to wait for the app server to reboot. So even during app server "downtime", assets will continue to be served.

@arekbartnik
Copy link
Author

arekbartnik commented May 2, 2023

@pcattori I've checked and svgs as dataulrs are blocked in Safari. Works in Chrome and Firefox. Here's a pen https://codepen.io/arekbartnik/pen/QWZqXzJ

But I think using use for svgs in React ecosystem is very rare - most import components with svg as jsx (I wanted to have a smaller JS bundle :))

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2023

🤖 Hello there,

We just published version v0.0.0-nightly-0e2763f-20230503 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!

@github-actions github-actions bot closed this as completed May 3, 2023
@pcattori
Copy link
Contributor

pcattori commented May 4, 2023

@arekbartnik after some more thought, I realized that serving the assets from the dev server doesn't actually help all that much for making HMR faster (for complicated reasons I won't bring up here). Which means that the original purpose of serving assets from dev server is obsoleted. Going to think about this a little more, but leaning towards just serving everything from the app server. Simpler, more similar to prod, and only one domain, so no CORS or cross-domain shenanigans. No need to use dataurls for svgs.

@pcattori
Copy link
Contributor

pcattori commented May 4, 2023

Related: #6306

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.16.1-pre.0 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants