vite.config.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // https://vitejs.dev/config/
  11. export default defineConfig({
  12. base: './',
  13. resolve: {
  14. alias: {
  15. '@': fileURLToPath(new URL('./src', import.meta.url))
  16. },
  17. extensions: [
  18. '.mjs',
  19. '.js',
  20. '.ts',
  21. '.jsx',
  22. '.tsx',
  23. '.json',
  24. '.vue',
  25. '.less'
  26. ]
  27. },
  28. plugins: [vue(), vueJsx(), vitePluginBuildId(), svgLoader(),
  29. Components({
  30. resolvers: [AntDesignVueResolver({importStyle: false})],
  31. directoryAsNamespace: true
  32. }),
  33. createHtmlPlugin({
  34. minify: true,
  35. /**
  36. * After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted
  37. * @default src/main.ts
  38. */
  39. entry: '/src/main.ts',
  40. /**
  41. * If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required
  42. * @default index.html
  43. */
  44. template: 'index.html',
  45. /**
  46. * Data that needs to be injected into the index.html ejs template
  47. */
  48. inject: {
  49. data: {
  50. title: 'Nginx UI'
  51. }
  52. }
  53. })
  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: 'http://127.0.0.1:9001/',
  69. changeOrigin: true,
  70. secure: false,
  71. ws: true
  72. }
  73. }
  74. },
  75. build: {
  76. chunkSizeWarningLimit: 1000
  77. }
  78. })