generated from waterbinnn/react-vite-shadcn-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
97 lines (95 loc) · 2.83 KB
/
vite.config.ts
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import Pages from 'vite-plugin-pages';
import { defineConfig } from 'vite';
import generateSitemap from 'vite-plugin-pages-sitemap';
import mdx from '@mdx-js/rollup';
import prerender from '@prerenderer/rollup-plugin';
import react from '@vitejs/plugin-react';
import rehypeHighlight from 'rehype-highlight';
import rehypeStringify from 'rehype-stringify';
import remarkFrontmatter from 'remark-frontmatter';
import remarkGfm from 'remark-gfm';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
import { visualizer } from 'rollup-plugin-visualizer';
import { viteStaticCopy } from 'vite-plugin-static-copy';
const isProd = process.env.NODE_ENV === 'production';
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tsconfigPaths(),
svgr(),
Pages({
dirs: 'src/pages',
onRoutesGenerated: () => {
if (isProd) {
return generateSitemap({
routes: ['/', '/about', '/archive', '/bookmark'],
hostname: 'https://www.delook.co.kr/',
});
}
},
}),
viteStaticCopy({
targets: [
{
src: 'public/manifest.json',
dest: '.',
},
],
}),
mdx({
remarkPlugins: [remarkGfm, remarkFrontmatter, [remarkMdxFrontmatter, { name: 'metaData' }]],
rehypePlugins: [[rehypeHighlight, { detect: true }], rehypeStringify],
}),
visualizer({
open: false,
emitFile: process.env.NODE_ENV === 'production',
}),
prerender({
routes: ['/', '/about', '/archive', '/bookmark'],
renderer: '@prerenderer/renderer-puppeteer',
server: {
port: 3000,
host: 'localhost',
},
rendererOptions: {
maxConcurrentRoutes: 1,
renderAfterTime: 500,
},
postProcess(renderedRoute) {
renderedRoute.html = renderedRoute.html
.replace(/http:/i, 'https:')
.replace(/(https:\/\/)?(localhost|127\.0\.0\.1):\d*/i, 'https://delook.co.kr');
},
}),
],
build: {
outDir: 'dist',
rollupOptions: {
input: {
main: './index.html',
},
output: {
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
form: ['react-hook-form', '@hookform/resolvers', 'zod'],
radix: [
'@radix-ui/react-toast',
'@radix-ui/react-popover',
'@radix-ui/react-tooltip',
'@radix-ui/react-dialog',
'@radix-ui/react-checkbox',
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-label',
'@radix-ui/react-collapsible',
],
mdx: ['@mdx-js/react', 'rehype-highlight', 'remark-gfm'],
tailwind: ['tailwind-merge'],
},
},
},
},
base: './',
});