Short version : I’d like to create a single package that contains my game’s content assets (meshes, textures etc) that can be loaded from both a vite frontend and a node.js backend.
Short why : My game can run fully in browser without connecting to the server, or I can run the game server on a node.js backend and have clients connect to it. I want to use Babylon’s headless/null mode to load assets on the server so that things like hitboxes are sync’d
Setup
I have a package called kit-game-assets that I want to hold all my static game assets "textures, meshes etc
This package is referenced by another package called kit-game-core which I want to load the assets in kit-game-assets.
The kit-game-core package is referenced by a vite based frontend project called kit-frontend AND a node based backend project called kit-backend
I want the assets to be loaded in both envs.
Problem
In kit-game-core if I load that asset using
import assetTest from "kit-game-assets/assets/test/wf.png"
console.log(assetTest)
On the frontend this returns “/@fs/home/azim/code/kit/core/packages/kit-app/kit-game-assets/src/assets/test/wf.png” from the vite dev server, this is correct and vite intercepts @fs paths during development and correctly bundles them during prod build.
But on the backend this results in
node:internal/modules/esm/get_format:185
throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".png" for /home/azim/code/kit/core/packages/kit-app/kit-game-assets/src/assets/test/wf.png
I get this is more of a general node thing, but was hoping other people have had to tackle something like this to have a server and frontend aware of their assets.

