vite.config.js (1849B)
1 import { defineConfig } from 'vite'; 2 import react from '@vitejs/plugin-react'; 3 import { 4 previewServerOptions, 5 resolveAllowSearchIndexing, 6 resolveAllowedHosts, 7 robotsSeoPlugin, 8 } from './vite.shared.js'; 9 10 export default defineConfig(({ mode }) => { 11 const allowedHosts = resolveAllowedHosts(mode); 12 const allowSearchIndexing = resolveAllowSearchIndexing(mode); 13 14 return { 15 plugins: [react(), robotsSeoPlugin(allowSearchIndexing)], 16 build: { 17 target: 'es2020', 18 rollupOptions: { 19 output: { 20 manualChunks(id) { 21 if (id.includes('node_modules/react-dom') || id.includes('node_modules/react/')) { 22 return 'vendor-react'; 23 } 24 if (id.includes('node_modules/marked') || id.includes('node_modules/dompurify')) { 25 return 'vendor-markdown'; 26 } 27 if ( 28 id.includes('node_modules/orga') || 29 id.includes('node_modules/@orgajs') || 30 id.includes('node_modules/@codemirror') || 31 id.includes('node_modules/@lezer') || 32 id.includes('node_modules/unified') || 33 id.includes('node_modules/rehype') || 34 id.includes('node_modules/hast') || 35 id.includes('node_modules/vfile') || 36 id.includes('node_modules/oast-to-hast') 37 ) { 38 return 'vendor-org'; 39 } 40 }, 41 }, 42 }, 43 }, 44 server: { 45 ...previewServerOptions, 46 allowedHosts, 47 proxy: { 48 '/api': { 49 target: 'http://localhost:41738', 50 changeOrigin: true, 51 }, 52 }, 53 }, 54 preview: { 55 ...previewServerOptions, 56 allowedHosts, 57 proxy: { 58 '/api': { 59 target: 'http://localhost:41738', 60 changeOrigin: true, 61 }, 62 }, 63 }, 64 }; 65 });