Skip to content

Example Reference

Reference pages are ideal for outlining how things work in terse and clear terms. Less concerned with telling a story or addressing a specific use case, they should give a comprehensive outline of what you’re documenting.

Further reading

Example Vite Configurations

Example 1: Basic React Configuration

vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
});

Example 2: React Configuration with Server Settings

vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: {
host: 'localhost',
port: 3000,
},
});

Example 3: React Configuration with HMR and Proxy

vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: {
hmr: {
overlay: false,
},
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true,
},
},
},
});

Example 4: React Configuration with Open Option

vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: {
open: true,
host: '0.0.0.0',
port: 8080,
},
});