vite.config.ts 2.2 KB

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