-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
43 lines (41 loc) · 1.65 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
import { reactRouter } from '@react-router/dev/vite'
import tailwindcss from '@tailwindcss/vite'
import consola from 'consola'
import { visualizer } from 'rollup-plugin-visualizer'
import { isCI, isProduction, isTest } from 'std-env'
import { type Logger, defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
// @ref: https://remix.run/docs/en/main/future/vite#plugin-usage-with-other-vite-based-tools-eg-vitest-storybook
const isTestOrStorybook = process.env.NODE_ENV === 'test' || process.argv[1]?.includes('storybook')
const isCIOrProduction = isCI || isProduction
export default defineConfig(({ isSsrBuild }) => ({
plugins: [
tailwindcss(),
!isTestOrStorybook && reactRouter(),
// `emitFile` is necessary since React Router builds more than one bundle!
!isCIOrProduction && visualizer({ emitFile: true, template: 'treemap' }),
tsconfigPaths(),
],
server: { port: 3000, host: true },
build: {
manifest: true,
emptyOutDir: true,
chunkSizeWarningLimit: 1024 * 4,
reportCompressedSize: false,
minify: isProduction,
rollupOptions: isSsrBuild ? { input: './server/app.ts' } : undefined,
terserOptions: { format: { comments: false } },
},
esbuild: { legalComments: 'inline' },
customLogger: !isTest
? ({
info: (msg: string) => consola.withTag('vite').info(msg),
warn: (msg: string) => consola.withTag('vite').warn(msg),
warnOnce: (msg: string) => consola.withTag('vite').warn(msg),
error: (msg: string) => consola.withTag('vite').error(msg),
clearScreen: () => {},
hasErrorLogged: () => true,
hasWarned: false,
} as Logger)
: undefined,
}))