Giter Club home page Giter Club logo

Comments (5)

userquin avatar userquin commented on May 30, 2024

@haleksandre have you configured kit sw entry? https://vite-pwa-org.netlify.app/frameworks/sveltekit.html#generate-custom-service-worker

Latest kit pwa plugin version will delegate sw build to kit, and so you need to configure src/sw.ts in the kit config file. CHECK the entry in the docs, you will need to include/change a few things.

from sveltekit.

haleksandre avatar haleksandre commented on May 30, 2024

Yes, my svelte.config.js config is like so

import adapter from "@sveltejs/adapter-node";
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(),

	kit: {
		adapter: adapter({ out: "dist" }),
		env: {
			publicPrefix: "API_URL",
		},
		serviceWorker: {
			register: false,
		},
		files: {
			serviceWorker: "src/sw.ts",
		},
		csrf: {
			checkOrigin: process.env.NODE_ENV !== "development",
		},
	},
};

export default config;

It is peculiar that everything is building fine on my local using the exact same configs, files within the same image, and environment variables, but fails in the GitLab CI.

from sveltekit.

userquin avatar userquin commented on May 30, 2024

Can you show the gh pages output/dist folder?

from sveltekit.

userquin avatar userquin commented on May 30, 2024

Check if the output folder inside .sveltekit contains service-woker.js or sw.js (ot seems former is missing)

from sveltekit.

haleksandre avatar haleksandre commented on May 30, 2024

Turns out it was indeed an error caused by an environment variable. I did not realize that I had forgotten to add a .dockerignore file in the root, so the building process had access to the .env file when building locally on the host & inside a Dockerfile. On the CI, there were not such files so the imports of $env/static/private variables were throwing errors, as they did not exist. Svelte Kit was throwing errors but SvelteKitPWA wasn't catching them. It then tried to build regardless but then itself was throwing an error because the directory of the previous build process was missing. Perhaps add in the build process a way to catch & throw previous build step errors, if possible?

Anyways, thanks for taking the time to help me troubleshoot this issue. 👍

from sveltekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.