-
Notifications
You must be signed in to change notification settings - Fork 10
/
vite.config.js
141 lines (132 loc) · 4.2 KB
/
vite.config.js
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
/* 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, envToBool } 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';
dotenv.config();
const plugins = [vue()];
const testInclude = [];
const env = process.env;
const USE_HTTPS_DEV = envToBool(env.VITE_USE_HTTPS_DEV);
addNodePolyfills(plugins);
if (USE_HTTPS_DEV) {
plugins.push(basicSsl());
}
// PWA
plugins.push(
VitePWA({
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',
})
);
if (env.VITE_MODULE_TESTS) {
testInclude.push(`src/modules/${env.VITE_TEST_MODULE}/**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}`);
} else if (env.VITE_DIR_TESTS) {
testInclude.push(`${env.VITE_TEST_DIR}/**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}`);
} else if (!env.VITE_INTEGRATION_TESTS && !env.VITE_UNIT_TESTS) {
testInclude.push('src/**/*.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
} else if (env.VITE_INTEGRATION_TESTS) {
testInclude.push('src/!**!/!*.integration.spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
} else if (env.VITE_UNIT_TESTS) {
testInclude.push('src/!**/!(*.integration).spec.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
}
plugins.push(
vitePluginTransformIndexHtml({
APP_TITLE: appConfig.title,
APP_DESCRIPTION: appConfig.description,
APP_KEYWORDS: appConfig.keywords,
})
);
// 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: testInclude,
deps: {
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/utils/test/install.js', import.meta.url)),
],
globals: true,
// minThreads: 2,
// maxThreads: 3,
},
optimizeDeps: {
exclude: ['fantom-vue3-components'],
},
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 */