Edit this page

getVikeConfig()

Environment: development & build-time (Node.js/Deno/Bun)

Get the app's configurations that are available at config-time.

⚠️
It's a beta feature: expect breaking changes in any minor version update.

It only returns configurations that are available at config-time (i.e. at build- and dev-time). To get configurations at (production) runtime use globalContext.config and globalContext.pages instead.

// vite.config.js
 
import { getVikeConfig } from 'vike/plugin'
 
export default {
  plugins: [myVitePlugin()]
}
 
function myVitePlugin() {
  return {
    name: 'myVitePlugin',
    configResolved(config) {
      const vike = getVikeConfig(config)
      console.log(vike.config.prerender)
      console.log(vike.config.baseAssets)
      console.log(vike.config.baseServer)
      console.log(vike.pages['/pages/index'].config)
      console.log(vike.pages['/pages/product'].route)
      // ...
    },
    config(config) {
      // Also available here
      const vike = getVikeConfig(config)
    }
  }
}

See also