-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvite.config.ts
164 lines (160 loc) · 3.66 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import react from '@vitejs/plugin-react';
import autoprefixer from 'autoprefixer';
import dotenv from 'dotenv';
import fs from 'fs';
import postcssMixins from 'postcss-mixins';
import postcssNesting from 'postcss-nesting';
import postcssPresetEnv from 'postcss-preset-env';
import { defineConfig } from 'vite';
import htmlPlugin from 'vite-plugin-html-config';
import { VitePWA } from 'vite-plugin-pwa';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
import app from './app.json';
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({
css: {
postcss: {
plugins: [
postcssMixins({
mixinsDir: './src/styles/mixins',
}),
postcssNesting,
autoprefixer,
postcssPresetEnv,
],
},
},
server: {
https: {
key: fs.readFileSync(process.env.SSL_KEY),
cert: fs.readFileSync(process.env.SSL_CRT),
},
port: 3000,
},
plugins: [
react(),
tsconfigPaths(),
svgr({
exportAsDefault: true,
}),
VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
strategies: 'injectManifest',
workbox: {
cleanupOutdatedCaches: false,
},
manifest: {
name: app.title,
short_name: app.short,
description: app.description,
theme_color: app.color,
background_color: app.colorbkg,
start_url: '/',
scope: '/',
id: '/',
icons,
file_handlers: [
{
action: '/',
accept: {
'text/markdown': ['.md'],
},
},
],
screenshots: [
{
src: '/facebook.jpg',
type: 'image/png',
sizes: '1200x630',
},
],
shortcuts: [
{
name: 'Open New File',
short_name: 'New File',
description: 'Open an empty markdown file',
url: '/#new-file',
icons: app.iconSizes.map((size) => ({
src: `fav/newFile/pwa-${size}x${size}.png`,
sizes: `${size}x${size}`,
})),
},
],
},
}),
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',
},
],
}),
],
});