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