vite.config.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import react from '@vitejs/plugin-react-swc';
  2. import UnoCSS from 'unocss/vite';
  3. import { defineConfig, loadEnv, PluginOption } from 'vite';
  4. import svgr from 'vite-plugin-svgr';
  5. import tsconfigPaths from 'vite-tsconfig-paths';
  6. /// <reference types="vite-plugin-svgr/client" />
  7. // https://vite.dev/config/
  8. export default defineConfig(({ mode }) => {
  9. const config = loadEnv(mode, './');
  10. return {
  11. resolve: {
  12. alias: [],
  13. },
  14. plugins: [
  15. svgr() as PluginOption,
  16. react(),
  17. UnoCSS(),
  18. // pluginImport({
  19. // libraryName: '@nutui/nutui-react',
  20. // libraryDirectory: 'dist/esm',
  21. // style: (path: string) => {
  22. // const capitalized =
  23. // path.charAt(0).toUpperCase()
  24. // + path.slice(1)
  25. // return capitalized
  26. // },
  27. // camel2DashComponentName: true
  28. // }),
  29. tsconfigPaths() as PluginOption,
  30. ],
  31. css: {
  32. // modules: {
  33. // hashPrefix: 'prefix',
  34. // generateScopedName: '[name]__[local]__[hash:base64:5]',
  35. // },
  36. preprocessorOptions: {
  37. sass: {
  38. api: 'modern',
  39. additionalData: `@nutui/nutui-react/dist/styles/variables.scss`,
  40. silenceDeprecations: ['legacy-js-api', 'color-functions'],
  41. },
  42. scss: {
  43. api: 'modern',
  44. silenceDeprecations: ['legacy-js-api'],
  45. },
  46. },
  47. },
  48. server: {
  49. proxy: {
  50. '/api': {
  51. target: config.VITE_BASIC_URL,
  52. changeOrigin: true,
  53. secure: false,
  54. },
  55. },
  56. },
  57. };
  58. });