vite.config.ts 1.9 KB

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