forked from NYUCCL/smile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
98 lines (94 loc) · 2.96 KB
/
vite.config.js
File metadata and controls
98 lines (94 loc) · 2.96 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* eslint-disable import/no-extraneous-dependencies */
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite'
import Vue from '@vitejs/plugin-vue'
import path from 'path'
import handlebars from 'vite-plugin-handlebars'
import Inspect from 'vite-plugin-inspect'
import { execSync } from 'child_process'
//import preLoaderPlugin from './plugins/preloader'
import stripDevToolPlugin from './plugins/strip-devtool'
import generateQRCode from './plugins/generate-qr.js'
import tailwindcss from '@tailwindcss/vite'
import Icons from 'unplugin-icons/vite'
import Components from 'unplugin-vue-components/vite'
import IconsResolver from 'unplugin-icons/resolver'
import { fileURLToPath } from 'node:url'
import { readFileSync } from 'fs'
// Execute git environment generation script
execSync('sh scripts/generate_git_env.sh', { stdio: 'inherit' })
const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Read package.json to get version
const packageJson = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf8'))
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = {
...loadEnv(mode, `${process.cwd()}/env/`, ''),
...loadEnv('deploy', `${process.cwd()}/env/`, ''),
...loadEnv('git', `${process.cwd()}/env/`, ''),
}
// import.meta.env.VITE_NAME available here with: process.env.VITE_NAME
// import.meta.env.VITE_PORT available here with: process.env.VITE_PORT
return defineConfig({
// prettier-ignore
plugins: [
Inspect(),
stripDevToolPlugin(),
tailwindcss(),
Vue(),
Components({
resolvers: [
IconsResolver(),
],
}),
Icons({
compiler: 'vue3',
}),
generateQRCode(),
handlebars({
context: {
main_js: '/src/core/main.js',
//main_js: mode=='dashboard'? "/src/dev/dashboard/dashboard.js": "/src/core/main.js"
}
}),
//preLoaderPlugin(),
],
// if you need an additional page you have to list them here
// see https://vitejs.dev/guide/build.html#multi-page-app
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index.html'),
//dashboard: path.resolve(__dirname, 'dashboard.html'),
},
},
},
envDir: 'env',
base: process.env.VITE_DEPLOY_BASE_PATH,
server: {
port: process.env.VITE_DEV_PORT_NUM,
strictPort: true,
},
clearScreen: false,
test: {
globals: true,
environment: 'happy-dom',
coverage: {
enabled: false,
src: path.resolve(__dirname, './src'),
reporter: ['text', 'html'],
provider: 'v8',
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
vue: 'vue/dist/vue.esm-bundler.js',
},
},
define: {
__BUILD_TIME__: JSON.stringify(new Date().toLocaleDateString()),
'import.meta.env.VITE_SMILE_VERSION': JSON.stringify(packageJson.version),
},
})
}