vitjs / vit

🚀 React application framework inspired by UmiJS / 类 UmiJS 的 React 应用框架
MIT License
100 stars 7 forks source link

is vit support vite's `resolve.alias` ? #11

Open cdll opened 1 year ago

cdll commented 1 year ago

the code below seems not working :

// vite.config.ts
export default defineConfig({
  vitApp({
    // vit configs ...
  }),
  // some other vite configs ...
  resolve: {
    alias: {
      "~/": path.resolve(__dirname, "./"),
      "~": path.resolve(__dirname, "./node_modules/"),
      "@/": path.resolve(__dirname, "/src/"),
      "~@/": path.resolve(__dirname, "/src/"),
      "lodash": 'lodash-es',
      "~antd": path.resolve(__dirname, "./node_modules/antd/"),
    },
  },
})
yunsii commented 1 year ago

vitApp config should place in plugins. resolve.alias is Vite supported, not vitjs. On the other hand, you can try https://www.npmjs.com/package/vite-tsconfig-paths instead of manual configuration.