-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
59 lines (54 loc) · 1.33 KB
/
vite.config.js
File metadata and controls
59 lines (54 loc) · 1.33 KB
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
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import autoprefixer from 'autoprefixer'
import path from 'path'
import { defineConfig } from 'vite'
import mdPlugin from 'vite-plugin-markdown'
import sitemapPlugin from 'vite-plugin-sitemap'
import { homepage } from './package.json'
import pwaPluginConfig from './pwa.config'
import routes from './src/data/routes.json'
const routePaths = routes.map(route => route.path)
// https://vitejs.dev/config/
export default ({ mode }) => {
const isProd = mode === 'production'
return defineConfig({
plugins: [
react(),
tailwindcss(),
pwaPluginConfig,
mdPlugin.plugin({ mode: 'html' }),
sitemapPlugin({
hostname: homepage,
dynamicRoutes: routePaths
})
],
css: {
postcss: {
plugins: [autoprefixer()]
}
},
build: {
minify: 'esbuild',
cssCodeSplit: true,
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
// Move common libraries to a separate chunk
vendor: ['react', 'react-dom']
}
}
}
},
define: {
'window.IS_PROD': `${isProd}`,
'window.THEME_KEY': '"dark-mode"'
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
}
})
}