vite.config.ts 2.2 KB

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