vite.config.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. // import { createStyleImportPlugin } from "vite-plugin-style-import";
  4. import vueJsx from "@vitejs/plugin-vue-jsx";
  5. import legacy from "@vitejs/plugin-legacy";
  6. import AutoImport from "unplugin-auto-import/vite";
  7. import Components from "unplugin-vue-components/vite";
  8. import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
  9. import path from "path";
  10. function resolve(dir: string) {
  11. return path.join(__dirname, dir);
  12. }
  13. // https://vitejs.dev/config/
  14. export default defineConfig({
  15. plugins: [
  16. vue(),
  17. vueJsx(),
  18. legacy({
  19. targets: ["> 0.25%, not dead"],
  20. ignoreBrowserslistConfig: true,
  21. }),
  22. AutoImport({
  23. resolvers: [NaiveUiResolver()],
  24. }),
  25. Components({
  26. resolvers: [NaiveUiResolver()],
  27. }),
  28. // createStyleImportPlugin({
  29. // libs: [
  30. // {
  31. // libraryName: "@arco-design/web-vue",
  32. // esModule: true,
  33. // resolveStyle: (name) => {
  34. // // css
  35. // return `@arco-design/web-vue/es/${name}/style/css.js`;
  36. // // less
  37. // return `@arco-design/web-vue/es/${name}/style/index.js`;
  38. // },
  39. // },
  40. // ],
  41. // }),
  42. ],
  43. resolve: {
  44. alias: {
  45. "@": resolve("./src"),
  46. "@components": resolve("./src/components"),
  47. },
  48. },
  49. server: {
  50. host: "0.0.0.0",
  51. port: 3000,
  52. strictPort: true,
  53. cors: true,
  54. open: true,
  55. },
  56. });