SolidJSS
SolidJSโ€ข2y agoโ€ข
13 replies
Bersaelor

importing static assets (telling vinxi/vite about stuff other then png's)

Every other month, I feel like i'm facing this again.
How to import static assets in solidjs?

The docs https://docs.solidjs.com/solid-start/building-your-application/static-assets say:

Vite provides a way to import assets directly into your Solid components:

import logo from "./solid.png";


If I try the same with other stuff like *.svg or *.txt the import fails.
I did have a an older solidjs project where I could do

import sprite from '../../assets/img/sprite.svg';

In the old project I did this via
// vite.config.mts

import solidSvg from 'vite-plugin-solid-svg'

export default defineConfig({
  plugins: [suidPlugin(), solidPlugin(), solidSvg({ defaultAsComponent: false })],
 ...
})


Is there a way we can still do this with solidjs/start? Since we don't have a vite.config anymore?
Was this page helpful?