Skip to content

build/server/assets is empty on production build #13540

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

Closed
yashok111 opened this issue May 6, 2025 · 7 comments
Closed

build/server/assets is empty on production build #13540

yashok111 opened this issue May 6, 2025 · 7 comments

Comments

@yashok111
Copy link

I'm using React Router as a...

framework

Reproduction

The Default React Router template can be used for reproduction. Just create a new project with
npx create-react-router@latest --template remix-run/react-router-templates/default. Then run build script. In console you will see build logs like on screenshot that assumes that static assets were emitted to assets folder.

Image

But when you try to list files inside assets folder it actually empty. This issue leads to incorrect server side rendered layout.

Image

On last screenshot you can see actual server rendered html. No css styles and svg's

Image

System Info

System:
    OS: macOS 15.4.1
    CPU: (12) arm64 Apple M4 Pro
    Memory: 230.88 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 1.22.22 - ~/.yarn/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
  Browsers:
    Chrome: 136.0.7103.49
    Safari: 18.4
  npmPackages:
    @react-router/dev: ^7.5.3 => 7.5.3
    @react-router/node: ^7.5.3 => 7.5.3
    @react-router/serve: ^7.5.3 => 7.5.3
    react-router: ^7.5.3 => 7.5.3
    vite: ^6.3.3 => 6.3.5

Used Package Manager

yarn

Expected Behavior

Server Side rendered output can access static assets generated by production build

Actual Behavior

Server build static assets is missing

@yashok111 yashok111 added the bug label May 6, 2025
@brophdawg11
Copy link
Contributor

I'm not sure why the output prints that those were generated to build/server/assets, but those aren't the ones used by the app in the browser. The app loads files from build/client/assets and those load fine in the default template - https://stackblitz.com/edit/github-3rxnof8n. There must be something else going on in your setup since it's not loading any of your JS/CSS/Images. If you can provide a reproduction we can look into what's going on.

@yashok111
Copy link
Author

I'm literally installed react-router framework through

  1. npx create-react-router@latest --template remix-run/react-router-templates/default (from docs)
  2. yarn build
  3. yarn start
    and get this issue. I get client bundle as expected, but server assets folder is empty somehow, so on server it renders without some svg's and css file, i have shown server response on screenshot above
Image

@yashok111
Copy link
Author

yashok111 commented May 6, 2025

This happens even in your example https://stackblitz.com/edit/github-3rxnof8n

  1. Open Network and reload page
Image
  1. Find html response from server
Image
  1. Open it and you can see that it rendered without css styles and some svg's
Image

@brophdawg11
Copy link
Contributor

I'm literally installed react-router framework through

So did I :)

The stackblitz works fine for me on a bunch of reloads - no issues loading any assets:

Image

Again, there must be something on on for you locally. Please provide a minimal reproduction in a github repo we can clone and install to remove Stackblit from the equation as well.

@timdorr
Copy link
Member

timdorr commented May 6, 2025

I also have those assets load up just fine in my browser. The logical assumption is the problem is occuring in your browser. Most likely it is some sort of browser extension that is blocking them from loading. It could possibly be a firewall as well. Regardless, that isn't a bug in the library.

@timdorr timdorr closed this as completed May 6, 2025
@yashok111
Copy link
Author

After some conversations with my colleagues, I finally realized my misunderstanding of the React Router approach to SSR. In my mind, SSR meant complete server-side rendering — like inlining all CSS and static assets into the HTML — so that we’d get a fully ready layout without any extra network requests for static assets. Sorry for wasting your time, guys.

@markdalgleish
Copy link
Member

markdalgleish commented May 7, 2025

@yashok111 No worries. This actually highlighted to me that we could be more transparent with how we're handling assets in the server build. I've opened a PR improving our build logs: #13547

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

4 participants