import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import AutoImport from "unplugin-auto-import/vite";export default ({}) => {return defineConfig({plugins: [uni(),AutoImport({include: [/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx/\.vue$/,/\.vue\?vue/, // .vue],imports: ["vue", "uni-app","vue-router"],dts: "typings/auto-imports.d.ts", // 针对ts类型定义文件dirs: ['./src/api'], // 自动导入接口文件}),],});
};
所有针对vue、uniapp、vue-router的导入都不用手动去写了
另外:
uniapp 如果无法使用npm,需初始化npm工程
npm init -y