#Importing static assets as url

1 messages · Page 1 of 1 (latest)

oblique spire
#

Is there a way to import static assets as url. As in ViteJS we can suffix the path with ?url

regal quarry
#

in normal runtime, it will print a path to the file, and in bun file.html thing (the fullstack & static html builder) it'll copy it as an asset and add hash (so like vite)

oblique spire
#

ok, I've tried it, but it doesn't seem to follow my path re-mapping
@/assets/img/switch-on.svg
in my tsconfig

    "rootDir": ".",
    "paths": {
      "@/*": [
        "./src/*"
      ]

the source:

import imgSwitchOnUrl from '@/assets/img/switch-on.svg' with { type: 'file' };
...
      <img
        className="ToggleIcon"
        alt=""
        src={value ? imgSwitchOnUrl : imgSwitchOffUrl}
        onClick={onToggle}
      />

the result:

<img class="ToggleIcon" alt="" src="@/assets/img/switch-on.svg">