物管理前端
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.

89 lines
2.4 KiB

  1. import vue from '@vitejs/plugin-vue';
  2. import { resolve } from 'path';
  3. import { defineConfig, loadEnv, UserConfig, UserConfigExport } from 'vite';
  4. import eslint from 'vite-plugin-eslint';
  5. import html from 'vite-plugin-html';
  6. import tsconfigPaths from 'vite-tsconfig-paths';
  7. import viteSvgIcons from 'vite-plugin-svg-icons';
  8. const prefix = `monaco-editor/esm/vs`;
  9. export default (config: UserConfig): UserConfigExport => {
  10. const mode = config.mode as string;
  11. return defineConfig({
  12. base: './',
  13. compilerOptions: {
  14. isCustomElement: (tag) => tag.startsWith('easy-'),
  15. },
  16. optimizeDeps: {
  17. include: [
  18. `${prefix}/language/json/json.worker`,
  19. `${prefix}/language/css/css.worker`,
  20. `${prefix}/language/html/html.worker`,
  21. `${prefix}/language/typescript/ts.worker`,
  22. `${prefix}/editor/editor.worker`,
  23. ],
  24. },
  25. plugins: [
  26. vue(),
  27. html({
  28. inject: {
  29. injectData: {
  30. apiURL: loadEnv(mode, process.cwd()).VITE_APP_API,
  31. socketURL: loadEnv(mode, process.cwd()).VITE_APP_SOCKET,
  32. title: '',
  33. },
  34. },
  35. minify: true,
  36. }),
  37. tsconfigPaths(),
  38. eslint({
  39. cache: false,
  40. fix: false,
  41. include: ['src/**/*.ts', 'src/**/*.vue'],
  42. }),
  43. viteSvgIcons({
  44. iconDirs: [resolve(__dirname, 'src/assets/icons/svg')],
  45. symbolId: 'icon-[dir]-[name]',
  46. }),
  47. ],
  48. build: {
  49. chunkSizeWarningLimit: 1024,
  50. rollupOptions: {
  51. output: {
  52. manualChunks: {
  53. monacoeditor: ['monaco-editor'],
  54. quill: ['quill'],
  55. lodash: ['lodash'],
  56. lib: ['sortablejs', 'vxe-table', 'xe-utils'],
  57. vlib: ['vue', 'vue-router', 'vuex', 'vue-i18n', 'element-plus'],
  58. },
  59. },
  60. },
  61. },
  62. resolve: {
  63. alias: {
  64. // 配置别名
  65. '@': resolve(__dirname, './src'),
  66. 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
  67. },
  68. },
  69. server: {
  70. open: true, // 自动启动浏览器
  71. host: '0.0.0.0', // localhost
  72. port: 8001, // 端口号
  73. https: false,
  74. // 接口代理
  75. proxy: {
  76. '/thing/': {
  77. // 远程请求 代理到后端服务端口
  78. target: "http://192.168.8.108:2020/",
  79. changeOrigin: true // 允许跨域
  80. },
  81. '/thing/websocket': {
  82. target: 'ws://192.168.8.101:81/',
  83. ws: true,
  84. },
  85. },
  86. },
  87. });
  88. };