#Treat a .tsx file as a static file

1 messages ยท Page 1 of 1 (latest)

remote pagoda
#

Howdy ๐Ÿ‘‹, I'm building some samples for excalibur.js games with vite! @junior jungle Sent me your way!

I'm having some trouble treating a .tsx file as a static file instead of a typescript react file. The motivation behind this is I'm using a program called Tiled (https://www.mapeditor.org/) that generates tileset .tsx xml files with that same extension (they are not related to react at all an unfortunate extension collision). I've been up and down trying various things, such as excluding .tsx from the esbuild configuration, or explicitly including .tsx as an assetInclude but no avail.

Changing the extension to something like .tssx works as I expect in the src/resources.ts file in the sample repo, and I'm able to load the asset url in the dev server.

Here is a small example repo https://github.com/excaliburjs/sample-tiled-vite (I have similar working repos for webpack https://github.com/excaliburjs/sample-tiled-webpack and and parcel https://github.com/excaliburjs/sample-tiled-parcel)

Let me know if you have any ideas! Or if there is a better way to accomplish what I'm trying to do with static assets in vite.

GitHub

Excalibur Sample using the Tiled Plugin w/ Vite. Contribute to excaliburjs/sample-tiled-vite development by creating an account on GitHub.

GitHub

Excalibur Sample using the Tiled Plugin w/ Webpack - GitHub - excaliburjs/sample-tiled-webpack: Excalibur Sample using the Tiled Plugin w/ Webpack

sweet condor
#

wait uh do you need the content or the URL

remote pagoda
#

I need the final url, not the content in this case. I need to pass the url to the underlying library to load the final asset location

#

One bummer is the Tiled resources include urls embedded in them, so I need to override the path resolution to provide the final bundled url paths

remote pagoda
#

Really I want import tsxPath from '../res/tileset.tsx?url'; to give me the url like import tmxPath from '../res/first-level.tmx?url'; does