-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
104 lines (97 loc) · 2.41 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
import { readFile } from 'fs/promises'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import svgrPlugin from 'vite-plugin-svgr'
import { ViteWebfontDownload } from 'vite-plugin-webfont-dl'
import { createHtmlPlugin } from 'vite-plugin-html'
import { VitePWA } from 'vite-plugin-pwa'
// Custom build scripts
import {
getGitRevision,
getGitBranch,
headMetadata,
viteServiceWorker,
} from './scripts'
// Relative alias
import { alias } from './vite-alias.config'
// https://vitejs.dev/config/
/** @type {import('vite').UserConfig} */
export default defineConfig({
root: './',
build: {
outDir: 'build',
sourcemap: true,
},
publicDir: './src/static',
define: {
__GIT_REVISION__: JSON.stringify(getGitRevision()),
__GIT_BRANCH__: JSON.stringify(getGitBranch()),
__PROJECT_SOURCE__: JSON.stringify('https://github.com/ZEBAS204/I-GEN'),
__CONTRIBUTE_TRANSLATION__: JSON.stringify(
'https://github.com/ZEBAS204/I-GEN/blob/master/CONTRIBUTING.md#translation-contributions'
),
},
server: {
port: '3000',
},
plugins: [
react(),
svgrPlugin({
svgrOptions: {
icon: true,
},
}),
ViteWebfontDownload([
'https://fonts.googleapis.com/css2?family=Inter:wght@600;700',
'https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700',
]),
createHtmlPlugin({
verbose: true,
minify: true,
/**
* After writing entry here, you will not need to add script tags in `index.html`, the original tags need to be deleted
* @default src/main.ts
*/
entry: 'src/index.jsx',
/**
* If you want to store `index.html` in the specified folder, you can modify it, otherwise no configuration is required
* @default index.html
*/
template: 'index.html',
inject: {
data: {
// Title to be used in the document
title: 'I-GEN | Multilanguage Random Word Generator',
},
// HTML Tags to inject into the document
tags: [...headMetadata()],
},
}),
VitePWA(viteServiceWorker),
],
resolve: {
alias: alias(),
},
//* Handle JS files with JSX syntax
esbuild: {
loader: 'jsx',
include: /src\/.*\.jsx?$/,
exclude: [],
},
optimizeDeps: {
include: [],
esbuildOptions: {
plugins: [
{
name: 'load-js-files-as-jsx',
setup(build) {
build.onLoad({ filter: /src\\.*\.js$/ }, async (args) => ({
loader: 'jsx',
contents: await readFile(args.path, 'utf8'),
}))
},
},
],
},
},
})