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 |
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { previewServerOptions, resolveAllowedHosts } from './vite.shared.js';
export default defineConfig(({ mode }) => {
const allowedHosts = resolveAllowedHosts(mode);
return {
plugins: [react()],
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';
}
},
},
},
},
server: {
...previewServerOptions,
allowedHosts,
},
preview: {
...previewServerOptions,
allowedHosts,
},
};
});
|