-
Notifications
You must be signed in to change notification settings - Fork 27
/
vite.config.ts
103 lines (100 loc) · 2.52 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
import { VitePWA } from 'vite-plugin-pwa';
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import path from 'path';
import fs from 'fs';
function baseUrl() {
const baseArgIndex = process.argv.indexOf('--base');
if (baseArgIndex !== -1 && baseArgIndex + 1 < process.argv.length) {
return process.argv[baseArgIndex + 1];
}
return null;
}
(function () {
// create a app.json with version using process.env.npm_package_version
const appJson = path.resolve('./src/app.json');
const content = {
version: process.env.npm_package_version
};
fs.writeFileSync(appJson, JSON.stringify(content, null, 2));
})();
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@/src': path.resolve('./src'),
'@': path.resolve('./src/lib')
}
},
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version)
},
base: '/Notpad/',
build: {
outDir: 'www',
rollupOptions: {
output: {
// https://github.com/vitejs/vite/discussions/9440#discussioncomment-5913798
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
}
}
}
},
server: {
port: 5173,
strictPort: true
},
plugins: [
svelte(),
VitePWA({
registerType: 'autoUpdate',
injectRegister: 'auto',
base: baseUrl() ?? '/Notpad/',
pwaAssets: {
disabled: false,
config: true
},
manifest: {
name: 'Notpad',
short_name: 'Notpad',
description: 'Windows like notpad for cross platform.',
theme_color: '#888888',
background_color: '#d4d4d4',
icons: [
{
purpose: 'maskable',
sizes: '512x512',
src: 'icon512_maskable.png',
type: 'image/png'
},
{
purpose: 'any',
sizes: '512x512',
src: 'icon512_rounded.png',
type: 'image/png'
}
],
orientation: 'any',
display: 'standalone',
dir: 'ltr',
lang: 'en-IN',
start_url: '/Notpad',
scope: '.'
},
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
cleanupOutdatedCaches: true,
clientsClaim: true
},
devOptions: {
enabled: false,
navigateFallback: 'index.html',
suppressWarnings: true,
type: 'module'
}
})
]
});