vite.config.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {defineConfig} from 'vite'
  2. import path from 'path'
  3. import {createVuePlugin} from 'vite-plugin-vue2'
  4. import envCompatible from 'vite-plugin-env-compatible'
  5. import {viteCommonjs} from '@originjs/vite-plugin-commonjs'
  6. import vueTemplateBabelCompiler from 'vue-template-babel-compiler'
  7. import styleImport from 'vite-plugin-style-import'
  8. //import AntdMomentResolver from 'vite-plugin-antdv1-momentjs-resolver'
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. resolve: {
  12. alias: [
  13. {
  14. find: /^~/,
  15. replacement: ''
  16. },
  17. {
  18. find: '@',
  19. replacement: path.resolve(__dirname, 'src')
  20. }
  21. ],
  22. extensions: [
  23. '.mjs',
  24. '.js',
  25. '.ts',
  26. '.jsx',
  27. '.tsx',
  28. '.json',
  29. '.vue'
  30. ]
  31. },
  32. plugins: [
  33. createVuePlugin({
  34. jsx: true,
  35. vueTemplateOptions: {
  36. compiler: vueTemplateBabelCompiler
  37. }
  38. }),
  39. viteCommonjs(),
  40. envCompatible(),
  41. styleImport({
  42. libs: [
  43. {
  44. libraryName: 'ant-design-vue',
  45. esModule: true,
  46. resolveStyle: (name) => {
  47. return `ant-design-vue/es/${name}/style/index`
  48. },
  49. }
  50. ],
  51. }),
  52. //AntdMomentResolver(),
  53. ],
  54. css: {
  55. preprocessorOptions: {
  56. css: {},
  57. postcss: {},
  58. less: {
  59. javascriptEnabled: true
  60. }
  61. }
  62. },
  63. server: {
  64. proxy: {
  65. '/api': {
  66. target: 'https://nginx.jackyu.cn/',
  67. changeOrigin: true,
  68. secure: false,
  69. ws: true,
  70. },
  71. },
  72. },
  73. build: {},
  74. })