-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.ts
77 lines (72 loc) · 2.27 KB
/
vite.config.ts
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 { fileURLToPath, URL } from 'node:url';
import { existsSync } from 'node:fs';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import copy from 'rollup-plugin-copy';
const getFileFromRepo = (file: string) =>
existsSync(fileURLToPath(new URL(`../node_modules/${file}`, import.meta.url)))
? fileURLToPath(new URL(`../node_modules/${file}`, import.meta.url))
: fileURLToPath(new URL(`./node_modules/${file}`, import.meta.url));
// eslint-disable-next-line prefer-const
let config = defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
compatConfig: {
MODE: 2,
},
},
},
}),
copy({
targets: [
{
src: [
`${require('swagger-ui-dist').getAbsoluteFSPath()}/*.{js,css,html,png}`,
`!${require('swagger-ui-dist').getAbsoluteFSPath()}/**/index.html`,
getFileFromRepo('axios/dist/axios.min.js'),
fileURLToPath(new URL('./src/main/webapp/swagger-ui/index.html', import.meta.url)),
],
dest: 'target/classes/static/swagger-ui',
},
],
hook: 'writeBundle',
}),
],
root: fileURLToPath(new URL('./src/main/webapp/', import.meta.url)),
publicDir: fileURLToPath(new URL('./target/classes/static/public', import.meta.url)),
cacheDir: fileURLToPath(new URL('./target/.vite-cache', import.meta.url)),
build: {
emptyOutDir: true,
outDir: fileURLToPath(new URL('./target/classes/static/', import.meta.url)),
rollupOptions: {
input: {
app: fileURLToPath(new URL('./src/main/webapp/index.html', import.meta.url)),
},
},
},
resolve: {
alias: {
vue: '@vue/compat/dist/vue.esm-bundler.js',
'@': fileURLToPath(new URL('./src/main/webapp/app/', import.meta.url)),
},
},
define: {
I18N_HASH: '"generated_hash"',
SERVER_API_URL: '"/"',
APP_VERSION: `"${process.env.APP_VERSION ? process.env.APP_VERSION : 'DEV'}"`,
},
server: {
proxy: Object.fromEntries(
['/api', '/management', '/v3/api-docs', '/h2-console'].map(res => [
res,
{
target: 'http://localhost:8080',
},
]),
),
},
});
// jhipster-needle-add-vite-config - JHipster will add custom config
export default config;