| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { defineConfig } from 'vite'
- import react from '@vitejs/plugin-react'
- import path from 'path'
- import fs from 'fs'
- // 检测SSL证书是否存在
- const sslKeyPath = path.resolve(__dirname, '../ssl/key.pem')
- const sslCertPath = path.resolve(__dirname, '../ssl/cert.pem')
- const hasSSL = fs.existsSync(sslKeyPath) && fs.existsSync(sslCertPath)
- // https://vitejs.dev/config/
- export default defineConfig({
- plugins: [react()],
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src'),
- },
- },
- server: {
- port: 5173,
- host: true, // 允许通过IP访问(0.0.0.0)
- // 自动启用HTTPS(如果证书存在)
- https: hasSSL ? {
- key: fs.readFileSync(sslKeyPath),
- cert: fs.readFileSync(sslCertPath),
- } : false,
- },
- build: {
- outDir: 'dist',
- sourcemap: false,
- rollupOptions: {
- output: {
- manualChunks: {
- 'react-vendor': ['react', 'react-dom'],
- 'recorder': ['recorder-core'],
- },
- },
- },
- },
- })
|