Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use kit.config.paths.base in local development #3752

Closed
metonym opened this issue Feb 6, 2022 · 2 comments
Closed

Use kit.config.paths.base in local development #3752

metonym opened this issue Feb 6, 2022 · 2 comments

Comments

@metonym
Copy link
Contributor

metonym commented Feb 6, 2022

Describe the problem

Consider the use case of deploying to GitHub Pages, where a base URL must be specified (e.g., the name of the repo).

However, when developing a SvelteKit app locally, the base URL cannot be specified. A "not found" error is shown when attempting to navigate to http://localhost/<base-url>/.

As a result, base must be conditionally applied only when building the app for production.

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter(),
    paths: {
       base: process.env.NODE_ENV === "production" ? "/repo-name" : "",
    },
  },
};

Prior Art

vite uses the base URL when developing locally:

// vite.config.js
import { defineConfig } from "vite";

export default defineConfig({
  base: "/repo-name/",
});

Run vite dev:

vite v2.7.13 dev server running at:

> Local: http://localhost:3000/repo-name/
> Network: use `--host` to expose

ready in 342ms.

Describe the proposed solution

The desired UX would be to avoid conditionally applying a base path:

/** @type {import('@sveltejs/kit').Config} */
const config = {
  kit: {
    adapter: adapter(),
    paths: {
       base: "/repo-name"
    },
  },
};

This would also make it easier to preview the app locally (i.e. svelte-kit preview).

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@babichjacob babichjacob added the p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. label Feb 6, 2022
@Conduitry
Copy link
Member

Sounds like a duplicate of #2958.

@babichjacob babichjacob removed the p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. label Feb 6, 2022
@metonym
Copy link
Contributor Author

metonym commented Feb 6, 2022

Oof. Yeah, this is a dupe.

@metonym metonym closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants