vite.config.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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:
  14. process.env.NODE_ENV == "production"
  15. ? "//infishwaibao.oss-cn-chengdu.aliyuncs.com/xihuadesign/"
  16. : "./",
  17. build: {
  18. rollupOptions: {
  19. input: {
  20. index: resolve(__dirname, "./index.html"),
  21. admin: resolve(__dirname, "./admin.html"),
  22. },
  23. },
  24. },
  25. plugins: [
  26. WindiCSS(),
  27. linaria({
  28. include: ["**/*.{ts,tsx}"],
  29. sourceMap: process.env.NODE_ENV !== "production",
  30. babelOptions: {
  31. presets: ["@babel/preset-typescript"],
  32. },
  33. }),
  34. // css({
  35. // output: (
  36. // styles: string,
  37. // styleNodes: Record<string, string>,
  38. // bundle: any
  39. // ) => {
  40. // console.log(bundle);
  41. // return "style.css";
  42. // },
  43. // }),
  44. Components({
  45. resolvers: [
  46. AntDesignVueResolver({
  47. // importLess: true
  48. }),
  49. ],
  50. }),
  51. vue(),
  52. vueJsx(),
  53. ],
  54. esbuild: {
  55. include: ["./src/**/*.tsx"],
  56. jsxInject: `import { getImageUrl } from '@/utils'`,
  57. },
  58. css: {
  59. preprocessorOptions: {
  60. less: {
  61. javascriptEnabled: true,
  62. },
  63. },
  64. },
  65. resolve: {
  66. alias: {
  67. "@": fileURLToPath(new URL("./src", import.meta.url)),
  68. },
  69. },
  70. });