vite 资源定位符 @

统一资源定位符

在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()]
})

你可能感兴趣的:(vite,vue3.0,从入门到精通,vue.js,前端,vite)