vite.config.ts 1.9 KB

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