|
1 | 1 | import react from '@vitejs/plugin-react'; |
2 | | -import { defineConfig } from 'vite'; |
| 2 | +import { defineConfig, loadEnv } from 'vite'; |
| 3 | +import { VitePWA } from 'vite-plugin-pwa'; |
3 | 4 |
|
4 | | -export default defineConfig({ |
5 | | - plugins: [react()], |
6 | | - build: { |
7 | | - rollupOptions: { |
8 | | - output: { |
9 | | - entryFileNames: `assets/[name]-[hash].js`, |
10 | | - chunkFileNames: `assets/[name].js`, |
11 | | - assetFileNames: function (file) { |
12 | | - return file.names.some((name) => name.includes('css')) |
13 | | - ? `assets/[name]-[hash].[ext]` |
14 | | - : `assets/[name].[ext]`; |
| 5 | +export default defineConfig(({ mode }) => { |
| 6 | + const env = loadEnv(mode, false); |
| 7 | + |
| 8 | + return { |
| 9 | + plugins: [ |
| 10 | + react(), |
| 11 | + VitePWA({ |
| 12 | + registerType: 'autoUpdate', |
| 13 | + manifest: { |
| 14 | + name: 'llama.ui', |
| 15 | + short_name: 'llama.ui', |
| 16 | + description: |
| 17 | + 'Minimal Interface for AI Companion that runs entirely in your browser.', |
| 18 | + display: 'standalone', |
| 19 | + theme_color: '#f8f8f8', |
| 20 | + background_color: '#f8f8f8', |
| 21 | + icons: [ |
| 22 | + { |
| 23 | + purpose: 'maskable', |
| 24 | + sizes: '512x512', |
| 25 | + src: 'icon512_maskable.png', |
| 26 | + type: 'image/png', |
| 27 | + }, |
| 28 | + { |
| 29 | + purpose: 'any', |
| 30 | + sizes: '512x512', |
| 31 | + src: 'icon512_rounded.png', |
| 32 | + type: 'image/png', |
| 33 | + }, |
| 34 | + { src: 'assets/favicon.ico', sizes: '48x48', type: 'image/x-icon' }, |
| 35 | + { src: 'assets/favicon.svg', sizes: 'any', type: 'image/svg+xml' }, |
| 36 | + ], |
| 37 | + start_url: env['BASE_URL'], |
| 38 | + orientation: 'any', |
| 39 | + lang: 'en', |
15 | 40 | }, |
16 | | - manualChunks: { |
17 | | - katex: ['katex'], |
18 | | - 'pdfjs-dist': ['pdfjs-dist'], |
| 41 | + }), |
| 42 | + ], |
| 43 | + build: { |
| 44 | + rollupOptions: { |
| 45 | + output: { |
| 46 | + entryFileNames: `assets/[name]-[hash].js`, |
| 47 | + chunkFileNames: `assets/[name].js`, |
| 48 | + assetFileNames: function (file) { |
| 49 | + return file.names.some((name) => name.includes('css')) |
| 50 | + ? `assets/[name]-[hash].[ext]` |
| 51 | + : `assets/[name].[ext]`; |
| 52 | + }, |
| 53 | + manualChunks: { |
| 54 | + katex: ['katex'], |
| 55 | + 'pdfjs-dist': ['pdfjs-dist'], |
| 56 | + }, |
19 | 57 | }, |
20 | 58 | }, |
21 | 59 | }, |
22 | | - }, |
23 | | - server: { |
24 | | - proxy: { |
25 | | - '/v1': 'http://localhost:8080', |
26 | | - '/props': 'http://localhost:8080', |
27 | | - }, |
28 | | - headers: { |
29 | | - 'Cross-Origin-Embedder-Policy': 'require-corp', |
30 | | - 'Cross-Origin-Opener-Policy': 'same-origin', |
| 60 | + server: { |
| 61 | + proxy: { |
| 62 | + '/v1': 'http://localhost:8080', |
| 63 | + '/props': 'http://localhost:8080', |
| 64 | + }, |
| 65 | + headers: { |
| 66 | + 'Cross-Origin-Embedder-Policy': 'require-corp', |
| 67 | + 'Cross-Origin-Opener-Policy': 'same-origin', |
| 68 | + }, |
31 | 69 | }, |
32 | | - }, |
| 70 | + }; |
33 | 71 | }); |
0 commit comments