Vite sets the relative path of the project after build, instead of the absolute path base

Vite sets the relative path of the project after build, instead of the absolute path base

For example, your project is just a branch of your website, not the main directory

For example, your vite project is called demo
and the path you put on the server is like this /test/demoinstead of/

At this point you need to set it up so that the packaged program runs in a relative path.

vite.config.ts

import {
    
     defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
    
    
  base: './',   // 添加这一行即可
  plugins: [vue()],
})

Guess you like

Origin blog.csdn.net/KimBing/article/details/132765512