-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
141 lines (138 loc) · 3.13 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import react from '@vitejs/plugin-react';
import autoprefixer from 'autoprefixer';
import dotenv from 'dotenv';
import fs from 'fs';
import postcssNesting from 'postcss-nesting';
import postcssPresetEnv from 'postcss-preset-env';
import { defineConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
import { VitePWA } from 'vite-plugin-pwa';
import app from './app.json';
import htmlPlugin from 'vite-plugin-html-config';
dotenv.config();
const icons = [
...app.iconSizes.map((size) => ({
src: `fav/icon/pwa-${size}x${size}.png`,
sizes: `${size}x${size}`,
type: 'image/png',
purpose: 'any',
})),
...app.iconSizes.map((size) => ({
src: `fav/icon/maskable-icon-${size}x${size}.png`,
sizes: `${size}x${size}`,
type: 'image/png',
purpose: 'maskable',
})),
{
src: 'fav/icon/icon.svg',
type: 'image/svg+xml',
sizes: '512x512',
},
{
src: 'fav/icon/favicon.ico',
sizes: '72x72 96x96 128x128 256x256',
},
];
export default defineConfig({
build: {
target: 'es2022',
},
esbuild: {
target: 'es2022',
},
optimizeDeps: {
esbuildOptions: {
target: 'es2022',
},
},
css: {
postcss: {
plugins: [postcssNesting, autoprefixer, postcssPresetEnv],
},
},
...(fs.existsSync(process.env.SSL_KEY) && fs.existsSync(process.env.SSL_CRT)
? {
server: {
https: {
key: fs.readFileSync(process.env.SSL_KEY),
cert: fs.readFileSync(process.env.SSL_CRT),
},
port: process.env.PORT ? parseInt(process.env.PORT) : 8080,
},
}
: {}),
plugins: [
react(),
tsconfigPaths(),
VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
strategies: 'injectManifest',
workbox: {
cleanupOutdatedCaches: false,
},
manifest: {
name: '',
short_name: app.short,
description: app.description,
theme_color: app.color,
background_color: app.colorbkg,
start_url: '/',
scope: '/',
id: '/',
icons,
},
}),
svgr(),
htmlPlugin({
title: app.title,
metas: [
{
name: 'description',
content: app.description,
},
{
name: 'og:image',
content: '/facebook.jpg',
},
{
name: 'og:title',
content: app.title,
},
{
name: 'og:description',
content: app.description,
},
{
name: 'og:locale',
content: 'en_US',
},
{
name: 'og:type',
content: 'website',
},
{
name: 'twitter:card',
content: 'summary_large_image',
},
{
name: 'twitter:creator',
content: '@nic_o_martin',
},
{
name: 'twitter:title',
content: app.title,
},
{
name: 'twitter:description',
content: app.description,
},
{
name: 'twitter:image',
content: '/twitter.jpg',
},
],
}),
],
});