forked from wwWallet/wallet-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
77 lines (74 loc) · 2.02 KB
/
vite.config.ts
File metadata and controls
77 lines (74 loc) · 2.02 KB
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
import path from 'node:path';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import checker from 'vite-plugin-checker';
import { VitePWA } from 'vite-plugin-pwa';
import {
BrandingManifestPlugin,
MetadataImagePlugin,
MobileWrapperWKAppLinksPlugin,
RobotsTxtPlugin,
SitemapPlugin,
ThemePlugin,
} from './vite-plugins';
import tailwindcss from '@tailwindcss/vite';
import { getBrandingHash } from './branding';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const brandingHash = getBrandingHash(path.resolve('branding')); // Compute branding hash from your branding folder
process.env.VITE_BRANDING_HASH = brandingHash; // import.meta.env.VITE_BRANDING_HASH works in TS/JS
env.VITE_BRANDING_HASH = brandingHash; // VITE_BRANDING_HASH% works in index.html
return {
base: '/',
plugins: [
ThemePlugin(),
react(),
tailwindcss(),
svgr(),
checker({
eslint: {
lintCommand: 'eslint "./src/**/*.{js,jsx,ts,tsx}"',
}
}),
BrandingManifestPlugin(env),
MetadataImagePlugin(env),
RobotsTxtPlugin(env),
SitemapPlugin(env),
MobileWrapperWKAppLinksPlugin(env),
VitePWA({
registerType: 'autoUpdate',
injectRegister: null,
srcDir: 'src',
filename: 'service-worker.js', // Custom service worker (MUST exist in `src/`)
strategies: 'injectManifest', // Uses `src/service-worker.js` for caching
manifest: false, // Vite will use `public/manifest.json` automatically
injectManifest: {
maximumFileSizeToCacheInBytes: env.VITE_GENERATE_SOURCEMAP === 'true' ? 12 * 1024 * 1024 : 4 * 1024 * 1024,
},
}),
],
resolve: {
alias: {
'@': '/src',
},
},
optimizeDeps: {
include: ['wallet-common'],
},
server: {
host: true,
port: 3000,
open: true,
},
preview: {
host: true,
port: 3000,
open: true,
},
build: {
sourcemap: env.VITE_GENERATE_SOURCEMAP === 'true',
minify: env.VITE_GENERATE_SOURCEMAP !== 'true'
},
}
});