0

I'm having trouble deploying my SvelteKit application built using adapter-netlify. My static assets (images, webfonts, ...) located inside the /static directory are not included in the build. When I run the app in dev mode (npm run dev) everything works just fine, however, when I visit the deployed app I'm getting a lot of 404 responses. How can I configure adapter-netlify so that it includes everything inside /static?

This is my svelte.config.js:

import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';

const config = {
    preprocess: preprocess(),
    kit: {
        adapter: adapter(),
        prerender: {
            default: true
        },
        files: {
            assets: 'static',
            lib: 'src/lib'
        }
    }
};

export default config;

Note: I am not importing the assets as such in my component's script. I'm instead referencing them by their URL (which works fine in dev mode).

I wasn't able to find any resources related to my problem. Thank you in advance for any suggestions!

alex-schuster
  • 102
  • 1
  • 7

1 Answers1

0

Sveltekit moves everything in static folder to the root of the build so you should reference them without static in the path. So rather than something like <img src="static/image.png"> you'd use <img src="image.png">

Meptl
  • 1
  • Thanks for your answer! That was what I always expected, however if I run the build command, the build folder won't contain any files I put inside `static` just as if they don't exist at all. Could this be a problem with my above configuration? I also tried `adapter-node` but got the same issue. Static assets are just not served by the web server generated in `/build/index.js`. – alex-schuster Aug 10 '22 at 21:45