68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
import { pnpmResolve } from '@lilith/vite-plugin-pnpm-resolve';
|
|
|
|
const SINGLETON_PACKAGES = [
|
|
'react',
|
|
'react-dom',
|
|
'styled-components',
|
|
'framer-motion',
|
|
];
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
pnpmResolve(),
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
strategies: 'injectManifest',
|
|
srcDir: 'src',
|
|
filename: 'sw.ts',
|
|
includeAssets: ['assets/icons/*.png'],
|
|
// manifest served from public/manifest.json — disable plugin generation
|
|
manifest: false,
|
|
injectManifest: {
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff,woff2}'],
|
|
// sw.ts is the source; vite-plugin-pwa compiles it and injects __WB_MANIFEST
|
|
swSrc: 'src/sw.ts',
|
|
swDest: 'dist/sw.js',
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
dedupe: SINGLETON_PACKAGES,
|
|
},
|
|
optimizeDeps: {
|
|
include: [
|
|
...SINGLETON_PACKAGES,
|
|
'@emotion/is-prop-valid',
|
|
'shallowequal',
|
|
'stylis',
|
|
],
|
|
},
|
|
server: {
|
|
port: 5850,
|
|
host: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3850',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
'/socket.io': {
|
|
target: 'http://localhost:3850',
|
|
changeOrigin: true,
|
|
ws: true,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true,
|
|
target: 'es2022',
|
|
},
|
|
worker: {
|
|
format: 'es',
|
|
},
|
|
});
|