vite.config.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 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(), svgLoader(),
  34. Components({
  35. resolvers: [AntDesignVueResolver({importStyle: false})],
  36. directoryAsNamespace: true
  37. }),
  38. AutoImport({
  39. imports: ['vue', 'vue-router', 'pinia'],
  40. vueTemplate: true,
  41. }),
  42. DefineOptions(),
  43. createHtmlPlugin({
  44. minify: true,
  45. /**
  46. * After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted
  47. * @default src/main.ts
  48. */
  49. entry: '/src/main.ts',
  50. /**
  51. * If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required
  52. * @default index.html
  53. */
  54. template: 'index.html',
  55. /**
  56. * Data that needs to be injected into the index.html ejs template
  57. */
  58. inject: {
  59. data: {
  60. title: 'Nginx UI'
  61. }
  62. }
  63. })
  64. ],
  65. css: {
  66. preprocessorOptions: {
  67. less: {
  68. modifyVars: {
  69. 'border-radius-base': '5px'
  70. },
  71. javascriptEnabled: true
  72. }
  73. }
  74. },
  75. server: {
  76. proxy: {
  77. '/api': {
  78. target: 'http://127.0.0.1:9001/',
  79. changeOrigin: true,
  80. secure: false,
  81. ws: true
  82. }
  83. }
  84. },
  85. build: {
  86. chunkSizeWarningLimit: 1000
  87. }
  88. })