发布时间:2023-08-14 18:30
在vite中,使用resolve alias
find 使用路径的开头
replacement 对应的文件资源
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const path = require("path")
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, "src")
},
{
find: 'components',
replacement: path.resolve(__dirname, "src/components")
},
{
find: 'views',
replacement: path.resolve(__dirname, "src/views")
}
]
},
plugins: [vue()]
})