vite配置相对路径

vite.config.ts


const pathResolve = (pathStr: string) => {
  return path.resolve(__dirname, pathStr);
};
// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": pathResolve("./src"),
    },
  },

});

tsconfig.json

{
  "compilerOptions": {

    "baseUrl": ".",
    "paths": {"@/*":["src/*"]}

  }

}

posted @ 2024-02-28 22:01  皮豪  阅读(248)  评论(0编辑  收藏  举报