Skip to content

Allow to use different base for dev server and generated import paths #19980

@vincesp

Description

@vincesp

Description

As a developer using Vite in development mode, I want to configure the prefix used to generate the import paths separately from the prefix used by the dev server, so that I can run Vite in dev mode in a scenario with a reverse proxy that forwards traffic to different applications based on a URL prefix but removes that prefix when forwarding the request.
Currently, I can only set base in the Vite config which will apply both to the prefix used by the dev server and to the import paths.

Suggested solution

Add an option server.base that can override the shared base option. With this, we could do:

import { defineConfig } from "vite";

export default defineConfig({
  base: "/foo/",
  server: {
    base: "/",
  },
});

Alternative

Alternatively, the overriding option could be added as build.base:

import { defineConfig } from "vite";

export default defineConfig({
  build: {
    base: "/foo/",
  },
});

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions