skip to Main Content

I have created a svelte app and building app using SvelteKit everything is works fine.

I tried to deploy this app in firebase hosting but it fails. Sveltekit generating production build under .svelte-kit folder. I tried to change the public object value to ".svelte-kit" from firebase.json file but it returns error like there is no index.html and 404.html. What we need to change in firebase.json to make it work?

{
  "hosting": {
    "public" : "public",

    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

2

Answers


  1. While building svelte app for production we can configure build location to public using svelte.config.js file

       import adapter from '@sveltejs/adapter-static';
    
    import preprocess from 'svelte-preprocess';
    
    /** @type {import('@sveltejs/kit').Config} */
    const config = {
        // Consult https://github.com/sveltejs/svelte-preprocess
        // for more information about preprocessors
        preprocess: [
            preprocess({
              postcss: true,
            }),
          ],
    
        kit: {
            adapter: adapter({
                pages: 'public',
                assets: 'public',
                fallback: null,
                precompress: false
                }),
                prerender: {
                default: true
                }
        }
    };
    
    export default config;
    

    Here we should use @sveltejs/adapter-static adapter to build.

    No need to change firebase.json we can leave it as it is

    {
      "hosting": {
        "public" : "public",
    
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ]
      }
    }
    
    Login or Signup to reply.
  2. I have built an adapter for firebase which enables SSR for Firebase and supports CloudFunctions v2 for concurrency:
    sveltekit-adapter-firebase

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search