skip to Main Content

I’m trying to deploy a sveltekit app to firebase (bigginner with sveltekit). I assumed we’re going to build the app and get our index.html file but that is not the case with sveltkit.

I’m using svelte auto adapter( Required in my case)

"svelte": "^3.46.0"

Now I tried updating the firebase config file to be like this

{
  "hosting": {
    "public": "src",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  "rewrites": [
    {
      "source": "**",
      "destination": "/src/app.html"
    }
  ]
}

Also as per the priority of hosting order in firebase documentation
I deleted index.html file populated by firebase, yet still not working and I’m getting page not found error with This file does not exist and there was no index.html found in the current directory.

Any idea what am I missing?

2

Answers


  1. Chosen as BEST ANSWER

    For anyone looking for the answer, after a long searching day, I concluded this.

    As per the documentation firebase is not one of the supported environments. So I had to adapt my app to using a static adapter and updated:

    svelte config like this:

    const config = {
        kit: {
            adapter: adapter({
                pages:"build",
                assets:"build",
                fallback: "index.html",
                precompress: true,
                strict:true
            })
        }
    };
    

    firebase config

    {
      "hosting": {
        "public": "build",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "rewrites": [
          {
            "source": "**",
            "destination": "/index.html"
          }
        ]
      },
      "rewrites": [
        {
          "source": "**",
          "destination": "/app.html"
        }
      ]
    }
    

    and in layouts

    export const ssr = false; 
    

    That's all, just build and deploy.


  2. There is a npm package for this as advertised on the landing page at kit.svelte.dev
    svelte-adapter-firebase
    https://github.com/jthegedus/svelte-adapter-firebase
    Follow the instructions in the readme. This package is in flux so there maybe some hacky fixes you need to do at the time of this post. Hopefully it will be fixed to align with SvleteKit 1.0 soon

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