vite.config.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. css: {
  53. preprocessorOptions: {
  54. less: {
  55. modifyVars: {
  56. 'border-radius-base': '4px',
  57. },
  58. javascriptEnabled: true,
  59. }
  60. },
  61. },
  62. server: {
  63. proxy: {
  64. '/api': {
  65. target: 'https://nginx.jackyu.cn/',
  66. changeOrigin: true,
  67. secure: false,
  68. ws: true,
  69. },
  70. },
  71. },
  72. build: {
  73. chunkSizeWarningLimit: 600
  74. }
  75. })