Skip to content

Allow accessing Vite mode from config.ts #4183

@Peque

Description

@Peque

Is your feature request related to a problem? Please describe.

With Vite, I can access the --mode flag with:

import { loadEnv, defineConfig } from 'vite'

export default ({ mode }) => {
  return defineConfig({
    titleTemplate: mode,
  })
}

With Vitepress, however, this does not seem to be possible, since this command always results in mode == "development":

vitepress dev docs --mode foo

Describe the solution you'd like

Executing this command:

vitepress dev docs --mode foo

Should make this code pass:

import { loadEnv, defineConfig } from 'vitepress'

export default ({ mode }) => {
  if (mode != "foo") {
    throw new Error(mode);
  }
  return defineConfig({
    titleTemplate: mode,
  })
}

Describe alternatives you've considered

Haven't found a suitable alternative. Are there any?

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions