路径别名同样需要在vite.config.ts
中配置,此时具体配置如下:
import { join} from "path"; // 此处如果报错则安装 node/path依赖
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
export default defineConfig({
plugins: [vue(), vueJsx()],
server: {
port: 8888
},
resolve: {
alias: {
"@": join(__dirname, "/src"),
},
},
});