-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
66 lines (63 loc) · 1.91 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
import { defineConfig } from 'vite'
import { defaultExclude } from 'vitest/config'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import { vitePlugin as remix } from '@remix-run/dev'
import { installGlobals } from '@remix-run/node'
import mdx from '@mdx-js/rollup'
import remarkFronmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
import remarkSmartypants from 'remark-smartypants'
import rehypeUnwrapImages from 'rehype-unwrap-images'
import rehypePrettyCodeConfigured from './etc/rehype-pretty-code-configured'
import cloudinary from './etc/vite-plugin-cloudinary'
import resolveConfig from 'tailwindcss/resolveConfig'
import tailwindConfig from './tailwind.config.js'
import { PORT } from './consts'
installGlobals()
const fullTailwindConfig = resolveConfig(tailwindConfig)
export default defineConfig(({ mode }) => {
return {
plugins: [
tsconfigPaths(),
mode === 'test' && react(),
mdx({
remarkPlugins: [
remarkFronmatter,
remarkMdxFrontmatter,
remarkSmartypants,
],
rehypePlugins: [rehypeUnwrapImages, rehypePrettyCodeConfigured],
}),
cloudinary(),
mode !== 'test' &&
remix({
ignoredRouteFiles: ['**/*.test.{ts,tsx}'],
}),
],
define: {
...Object.fromEntries(
Object.entries(fullTailwindConfig.theme.screens).map(([key, value]) => [
`import.meta.env.SCREEN_${key.toUpperCase()}`,
JSON.stringify(value),
]),
),
},
server: {
port: PORT,
},
build: {
assetsInlineLimit(filePath) {
if (filePath.endsWith('sprite.svg')) {
return false
}
},
},
test: {
globals: true,
environment: 'happy-dom',
setupFiles: ['./test/setup-test-env.ts'],
exclude: [...defaultExclude, './integration/**'],
},
}
})