vite.config.ts 2.2 KB

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