ChopFresh / vite.config.ts
pranav8tripathi@gmail.com
initr
8dc6b0b
import { defineConfig, ConfigEnv } from 'vite'
type CustomConfigEnv = Omit<ConfigEnv, 'command'> & { command: 'build' | 'serve' | 'preview' }
import path from 'path'
// Dynamic config so we don't require @vitejs/plugin-react during "preview"
export default defineConfig(async ({ command }: CustomConfigEnv) => {
const plugins = []
if (command!== 'preview') {
const { default: react } = await import('@vitejs/plugin-react')
plugins.push(react())
}
return {
plugins,
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
// Local dev only
server: {
host: '0.0.0.0',
port: 3000,
strictPort: true,
},
// Used on Hugging Face (production)
preview: {
host: '0.0.0.0',
port: 7860,
strictPort: true,
allowedHosts: ['pranav8tripathi-chopfresh.hf.space'],
},
}
})