vite.config.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {defineConfig} from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import {createHtmlPlugin} from 'vite-plugin-html'
  4. import Components from 'unplugin-vue-components/vite'
  5. import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers'
  6. import {fileURLToPath, URL} from 'url'
  7. import vueJsx from '@vitejs/plugin-vue-jsx'
  8. import vitePluginBuildId from 'vite-plugin-build-id'
  9. import svgLoader from 'vite-svg-loader'
  10. import VueMacros from 'unplugin-vue-macros/vite'
  11. // https://vitejs.dev/config/
  12. export default defineConfig({
  13. base: './',
  14. resolve: {
  15. alias: {
  16. '@': fileURLToPath(new URL('./src', import.meta.url))
  17. },
  18. extensions: [
  19. '.mjs',
  20. '.js',
  21. '.ts',
  22. '.jsx',
  23. '.tsx',
  24. '.json',
  25. '.vue',
  26. '.less'
  27. ]
  28. },
  29. plugins: [vitePluginBuildId(), svgLoader(),
  30. Components({
  31. resolvers: [AntDesignVueResolver({importStyle: false})],
  32. directoryAsNamespace: true
  33. }),
  34. VueMacros({
  35. plugins: {
  36. vue: vue(),
  37. vueJsx: vueJsx(),
  38. },
  39. }),
  40. createHtmlPlugin({
  41. minify: true,
  42. /**
  43. * After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted
  44. * @default src/main.ts
  45. */
  46. entry: '/src/main.ts',
  47. /**
  48. * If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required
  49. * @default index.html
  50. */
  51. template: 'index.html',
  52. /**
  53. * Data that needs to be injected into the index.html ejs template
  54. */
  55. inject: {
  56. data: {
  57. title: 'Nginx UI'
  58. }
  59. }
  60. })
  61. ],
  62. css: {
  63. preprocessorOptions: {
  64. less: {
  65. modifyVars: {
  66. 'border-radius-base': '5px'
  67. },
  68. javascriptEnabled: true
  69. }
  70. }
  71. },
  72. server: {
  73. proxy: {
  74. '/api': {
  75. target: 'http://127.0.0.1:9001/',
  76. changeOrigin: true,
  77. secure: false,
  78. ws: true
  79. }
  80. }
  81. },
  82. build: {
  83. chunkSizeWarningLimit: 1000
  84. }
  85. })