You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB

3 years ago
  1. const path = require('path');
  2. import {defineConfig} from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. // https://github.com/vuejs/jsx-next#syntax
  5. import vueJsx from '@vitejs/plugin-vue-jsx'
  6. // 按需引入
  7. import ViteComponent from 'unplugin-vue-components/dist/vite.js';
  8. import { AntDesignVueResolver } from 'unplugin-vue-components/dist/resolvers.js';
  9. // import {vitePluginChunk} from './IvzVitePlugins'
  10. // https://vitejs.dev/config/
  11. export default defineConfig((env)=>{
  12. return {
  13. plugins: [
  14. vue(),
  15. vueJsx(),
  16. // ViteComponent({
  17. // resolvers: [AntDesignVueResolver()],
  18. // }),
  19. // vitePluginChunk
  20. ],
  21. resolve: {
  22. alias: {
  23. '@': path.resolve(__dirname, './src'),
  24. '@msn': path.resolve(__dirname, './src/views')
  25. }
  26. },
  27. server: {
  28. proxy: {
  29. '^/api/*': {
  30. changeOrigin: true,
  31. // 线上测试地址, 只支持浏览数据
  32. // target: 'http://iot.iteaj.com/api',
  33. // 本地开发地址, 需要运行对应的java后端[https://gitee.com/iteaj/iboot]
  34. target: 'http://localhost:8085',
  35. rewrite: (path) => {
  36. return path.replace(/^\/api/, '')
  37. }
  38. },
  39. },
  40. cors: true,
  41. host: '0.0.0.0'
  42. },
  43. optimizeDeps: {
  44. include: [],
  45. },
  46. css: {
  47. preprocessorOptions: {
  48. less: {
  49. javascriptEnabled: true
  50. }
  51. }
  52. },
  53. build: {
  54. rollupOptions: {
  55. // external: ['ant-design-vue'],
  56. // output: {
  57. // format: 'module',
  58. // paths: {
  59. // 'ant-design-vue': 'http://localhost'
  60. // }
  61. // }
  62. },
  63. sourcemap: false,
  64. cssCodeSplit: true,
  65. polyfillModulePreload: false
  66. }
  67. }
  68. })