-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvite.config.mjs
163 lines (154 loc) · 4.73 KB
/
vite.config.mjs
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
/* eslint-disable no-undef */
import { fileURLToPath, URL } from 'url';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { VitePWA } from 'vite-plugin-pwa';
import { appConfig } from './src/config/app-config.js';
import { vitePluginTransformIndexHtml } from './src/plugins/vite-plugin-transform-index-html.js';
// import { addNodePolyfills } from './src/config/node-polyfills.js';
import * as dotenv from 'dotenv';
import basicSsl from '@vitejs/plugin-basic-ssl';
import { envToBool } from './src/config/utils.js';
dotenv.config();
const plugins = [vue()];
const env = process.env;
const USE_HTTPS_DEV = envToBool(env.VITE_USE_HTTPS_DEV);
const excludeTests = [
'src/plugins/web3-wallets/node_modules/**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
];
if (appConfig.flags.useWeb3Modal) {
// 'src/modules/faucet/**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
excludeTests.push('src/**/WalletPicker.spec.js');
excludeTests.push('src/**/LedgerAccountPickerC.spec.js');
excludeTests.push('src/**/AccountList*.spec.js');
}
// addNodePolyfills(plugins);
if (USE_HTTPS_DEV) {
plugins.push(basicSsl());
}
// PWA
plugins.push(
VitePWA({
// selfDestroying: true,
includeAssets: [
'favicon-16x16.png',
'favicon-32x32.png',
'favicon.ico',
'robots.txt',
'apple-touch-icon.png',
// 'fire2.gif',
],
manifest: {
name: appConfig.pwa.name,
short_name: appConfig.pwa.name,
theme_color: appConfig.pwa.mainColor,
background_color: appConfig.pwa.mainColor,
description: appConfig.pwa.description,
categories: appConfig.pwa.categories,
display: 'standalone',
icons: [
{
src: './pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: './pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
},
registerType: 'autoUpdate',
})
);
plugins.push(
vitePluginTransformIndexHtml({
APP_TITLE: appConfig.title,
APP_DESCRIPTION: appConfig.description,
APP_KEYWORDS: appConfig.keywords,
APP_IMAGE: appConfig.image,
})
);
// https://vitejs.dev/config/
export default defineConfig({
server: {
https: USE_HTTPS_DEV,
},
base: envToBool(env.VITE_SANDBOX_MODE) ? './' : undefined,
plugins,
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'~fantom-vue3-components': 'fantom-vue3-components',
},
},
test: {
// include: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
include: ['src/**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
exclude: excludeTests,
deps: {
optimizer: {
web: {
include: ['fantom-vue3-components'],
},
},
// inline: ['fantom-vue3-components'],
},
setupFiles: [
fileURLToPath(
new URL(
'node_modules/fantom-vue3-components/src/plugins/vue-test-plugins/install.js',
import.meta.url
)
),
fileURLToPath(
new URL('src/plugins/vue-test-plugins/install.js', import.meta.url)
),
fileURLToPath(new URL('src/config/test/install.js', import.meta.url)),
// fileURLToPath(new URL('test/setup.js', import.meta.url)),
],
globals: true,
// globalSetup: 'test/setup.js',
// minThreads: 2,
// maxThreads: 3,
onConsoleLog(log) {
if (
log.includes('Download the Vue Devtools extension') ||
log.includes('Lit is in dev mode.')
) {
return false;
}
},
},
optimizeDeps: {
exclude: ['fantom-vue3-components'],
},
// libraries for Ledger support needs this :(
define: {
global: true,
'process.env': {},
},
/*esbuild: {
keepNames: true,
},*/
/*build: {
commonjsOptions: {
// include: [/node_modules\/web3/],
},
},*/
/*build: {
rollupOptions: {
plugins: [
/!*NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),*!/
// Enable rollup polyfills plugin
// used during production bundling
nodePolyfills(),
],
},
},*/
});
/* eslint-enable no-undef */