dykj-ground-floor/vite.config.ts
2024-05-30 20:17:51 +08:00

23 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 这部分从Node.js的内置模块导入了两个函数fileURLToPath 和 URL。它们主要用于处理文件路径和URL之间的转换这对于Vite配置中的别名功能特别有用。
import { fileURLToPath, URL } from 'node:url'
// 这里导入了Vite的defineConfig函数以及Vue和Vue JSX的插件。
import { defineConfig } from 'vite'
//
import vue from '@vitejs/plugin-vue'
//
import vueJsx from '@vitejs/plugin-vue-jsx'
// 通过defineConfig函数定义配置对象并在其plugins属性中添加了之前导入的Vue和Vue JSX插件。这两个插件会在Vite启动时自动应用到项目中使得Vue和Vue JSX的功能得以实现
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx(),
],
resolve: {
// 通过alias属性设置了一个路径别名。在这里@符号被映射到了项目源码目录(src)的绝对路径。这样做可以让开发者在导入模块时使用更简短的路径,
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})