vite.config.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { defineConfig, normalizePath } from "vite";
  2. import { fileURLToPath, URL } from "node:url";
  3. import vue from "@vitejs/plugin-vue";
  4. import vueJsx from "@vitejs/plugin-vue-jsx";
  5. import linaria from "@linaria/rollup";
  6. import css from "rollup-plugin-css-only";
  7. import WindiCSS from "vite-plugin-windicss";
  8. import Components from "unplugin-vue-components/vite";
  9. import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
  10. import { resolve } from "path";
  11. // https://vitejs.dev/config/
  12. export default defineConfig({
  13. base: process.env.NODE_ENV == "production" ? "./" : "./",
  14. build: {
  15. rollupOptions: {
  16. input: {
  17. index: resolve(__dirname, "./index.html"),
  18. admin: resolve(__dirname, "./admin.html"),
  19. },
  20. },
  21. },
  22. plugins: [
  23. WindiCSS(),
  24. linaria({
  25. include: ["**/*.{ts,tsx}"],
  26. sourceMap: process.env.NODE_ENV !== "production",
  27. babelOptions: {
  28. presets: ["@babel/preset-typescript"],
  29. },
  30. }),
  31. // css({
  32. // output: (
  33. // styles: string,
  34. // styleNodes: Record<string, string>,
  35. // bundle: any
  36. // ) => {
  37. // console.log(bundle);
  38. // return "style.css";
  39. // },
  40. // }),
  41. Components({
  42. resolvers: [
  43. AntDesignVueResolver({
  44. // importLess: true
  45. }),
  46. ],
  47. }),
  48. vue(),
  49. vueJsx(),
  50. ],
  51. esbuild: {
  52. include: ["./src/**/*.tsx"],
  53. jsxInject: `import { getImageUrl } from '@/utils'`,
  54. },
  55. css: {
  56. preprocessorOptions: {
  57. less: {
  58. javascriptEnabled: true,
  59. },
  60. },
  61. },
  62. resolve: {
  63. alias: {
  64. "@": fileURLToPath(new URL("./src", import.meta.url)),
  65. },
  66. },
  67. });