-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
vite.config.ts
91 lines (84 loc) · 2.35 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* eslint-disable camelcase */
import { resolve } from 'node:path';
import react from '@vitejs/plugin-react';
import { ConfigEnv, loadEnv, UserConfig } from 'vite';
import { ManifestOptions, VitePWA, VitePWAOptions } from 'vite-plugin-pwa';
import svgr from 'vite-plugin-svgr';
const ReactCompilerConfig = {
target: '19',
};
const pwaOptions: Partial<VitePWAOptions | ManifestOptions> = {
registerType: 'autoUpdate',
categories: ['education', 'utilities'],
description:
'A translator app built using OpenAI GPT model to translate between languages. It is a PWA that can be installed on your phone or desktop.',
manifest: {
short_name: 'OpenAI Translator',
name: 'OpenAI Translator',
display: 'standalone',
icons: [
{
src: 'icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
purpose: 'maskable',
src: 'icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
purpose: 'maskable',
src: 'icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
start_url: '/',
theme_color: '#ffffff',
background_color: '#ffffff',
},
includeAssets: ['openai-translator-apple-touch-icon.png', 'favicon.png', 'locales/**/*.json', 'icons/*.{png,svg}'],
};
// https://vitejs.dev/config/
// local mode: development | test
// publishing mode: pre | prod
export default async function ({ command, mode }: ConfigEnv): Promise<UserConfig> {
const env = loadEnv(mode, __dirname);
return {
server: {
open: true,
},
base: env['VITE_PUBLIC_PATH'],
root: resolve(__dirname, 'src'),
build: {
// Specified by the relative path from root (= ./)
outDir: '../dist',
emptyOutDir: true,
},
plugins: [
react({
babel: {
plugins: [['babel-plugin-react-compiler', ReactCompilerConfig]],
},
}),
svgr(),
VitePWA(pwaOptions),
],
resolve: {
alias: {
'@/': `${__dirname}/src/`,
},
},
define: {
BUILD_TIME: JSON.stringify(new Date().toISOString()),
},
assetsInclude: ['favicon.png', 'openai-translator-apple-touch-icon.png', 'locales/**/*.json', 'icons/*.{png,svg}'],
};
}