pranav8tripathi@gmail.com commited on
Commit
8dc6b0b
·
1 Parent(s): 8563afe
Files changed (2) hide show
  1. vite.config.ts +3 -2
  2. vite.preview.config.mjs +11 -0
vite.config.ts CHANGED
@@ -1,10 +1,11 @@
1
  import { defineConfig, ConfigEnv } from 'vite'
 
2
  import path from 'path'
3
 
4
  // Dynamic config so we don't require @vitejs/plugin-react during "preview"
5
- export default defineConfig(async ({ command }: ConfigEnv) => {
6
  const plugins = []
7
- if (command !== 'preview') {
8
  const { default: react } = await import('@vitejs/plugin-react')
9
  plugins.push(react())
10
  }
 
1
  import { defineConfig, ConfigEnv } from 'vite'
2
+ type CustomConfigEnv = Omit<ConfigEnv, 'command'> & { command: 'build' | 'serve' | 'preview' }
3
  import path from 'path'
4
 
5
  // Dynamic config so we don't require @vitejs/plugin-react during "preview"
6
+ export default defineConfig(async ({ command }: CustomConfigEnv) => {
7
  const plugins = []
8
+ if (command!== 'preview') {
9
  const { default: react } = await import('@vitejs/plugin-react')
10
  plugins.push(react())
11
  }
vite.preview.config.mjs ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vite'
2
+
3
+ export default defineConfig({
4
+ preview: {
5
+ host: '0.0.0.0',
6
+ port: parseInt(process.env.PORT || '7860', 10),
7
+ strictPort: true,
8
+ // Allow HF Space host (add yours here) and localhost for local preview
9
+ allowedHosts: ['pranav8tripathi-chopfresh.hf.space', 'localhost'],
10
+ },
11
+ })