-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
39 lines (36 loc) · 1.07 KB
/
vite.config.ts
File metadata and controls
39 lines (36 loc) · 1.07 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
import { resolve } from 'node:path'
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
function serverOnly(): import('vite').Plugin {
return {
name: 'server-only',
resolveId(source, importer) {
if (source.endsWith('.server') || source.includes('.server.')) {
if (importer && !importer.includes('.server.') && !importer.includes('entry-server')) {
if (importer.endsWith('server.ts') || importer.includes('loaders.server')) {
return null
}
this.error(`Cannot import server-only module "${source}" from client code "${importer}"`)
}
}
return null
},
}
}
export default defineConfig({
plugins: [react(), tailwindcss(), serverOnly()],
resolve: {
alias: { '~': resolve(__dirname, 'src') },
},
build: {
rollupOptions: {
input: {
client: resolve(__dirname, 'index.html'),
},
},
},
ssr: {
external: ['react', 'react-dom', 'react-router', 'postgres', 'better-sqlite3', 'bcrypt'],
},
})