-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
81 lines (74 loc) · 1.77 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
/* eslint-disable camelcase, @typescript-eslint/no-magic-numbers */
// eslint-env node
import { readFileSync } from 'fs';
import { resolve } from 'path';
import { defineConfig, type UserConfig } from 'vite';
import { type ManifestOptions, VitePWA as vitePWA } from 'vite-plugin-pwa';
import { externalResources, internalResources } from './src/service-worker';
const manifest: Partial<ManifestOptions> = JSON.parse(readFileSync('./src/manifest.json', { encoding: 'utf8' }));
export default defineConfig(({ mode }) => {
const baseUrl = mode === 'production' ? 'https://owt.madcampos.dev/' : 'https://localhost:3000/';
const sslOptions = mode === 'production'
? false
: {
cert: readFileSync('./certs/server.crt', 'utf8'),
key: readFileSync('./certs/server.key', 'utf8')
};
const config: UserConfig = {
plugins: [
vitePWA({
registerType: 'prompt',
minify: true,
includeAssets: ['/icons/favicon.svg'],
manifest,
scope: baseUrl,
workbox: {
cleanupOutdatedCaches: true,
clientsClaim: true,
navigationPreload: false,
runtimeCaching: [
internalResources,
externalResources
]
},
devOptions: {
enabled: false
}
})
],
base: baseUrl,
envPrefix: 'APP_',
envDir: '../',
root: 'src',
publicDir: '../public',
clearScreen: false,
server: {
host: 'localhost',
// @ts-expect-error
https: sslOptions,
open: false,
cors: true,
port: 3000
},
build: {
target: 'esnext',
emptyOutDir: true,
outDir: '../dist',
rollupOptions: {
input: {
main: resolve('src/index.html')
},
output: {
generatedCode: 'es2015',
inlineDynamicImports: false
}
}
},
preview: {
// @ts-expect-error
https: sslOptions,
open: true
}
};
return config;
});