tranform Vue.config.js to vite.config.js build path

Viewed 4966

I tried to change the buildpath from webpack to vite:

publicPath:
    process.env.NODE_ENV === “production”
        ? “./” // prod
        : “/”, // dev

I want to show the litte site it in a subdirectory of a domain. How can I realize this with the vite.config

1 Answers

The equivalent Vite config option is base:

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  base: process.env.NODE_ENV === 'production'
          ? './' // prod
          : '/', // dev
})

GitHub demo

Related