vite.config.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }),
  30. createHtmlPlugin({
  31. minify: true,
  32. /**
  33. * After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted
  34. * @default src/main.ts
  35. */
  36. entry: '/src/main.ts',
  37. /**
  38. * If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required
  39. * @default index.html
  40. */
  41. template: 'index.html',
  42. /**
  43. * Data that needs to be injected into the index.html ejs template
  44. */
  45. inject: {
  46. data: {
  47. title: 'Nginx UI',
  48. },
  49. },
  50. }),
  51. ],
  52. define: {
  53. 'APP_VERSION': JSON.stringify(process.env.npm_package_version)
  54. },
  55. css: {
  56. preprocessorOptions: {
  57. less: {
  58. modifyVars: {
  59. 'border-radius-base': '4px',
  60. },
  61. javascriptEnabled: true,
  62. }
  63. },
  64. },
  65. server: {
  66. proxy: {
  67. '/api': {
  68. target: 'https://nginx.jackyu.cn/',
  69. changeOrigin: true,
  70. secure: false,
  71. ws: true,
  72. },
  73. },
  74. },
  75. build: {
  76. chunkSizeWarningLimit: 600
  77. }
  78. })