-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
95 lines (92 loc) · 2.45 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/// <reference types="vitest" />
import { resolve } from 'path';
import vuePlugin from '@vitejs/plugin-vue';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { ConfigEnv, defineConfig, loadEnv } from 'vite';
import eslintPlugin from 'vite-plugin-eslint';
import vuetify from 'vite-plugin-vuetify';
const axiosRedirectConfig = () => ({
name: 'serverProxy',
configureServer(server: any) {
const filter = function filter(pathname: any, req: any) {
return (
typeof req.headers['x-df-axios'] !== 'undefined' || (
pathname !== '/' &&
!pathname.startsWith('/@') &&
!pathname.startsWith('/vue') &&
!pathname.startsWith('/node_modules')
)
);
// return ;
};
server.middlewares.use(
'/',
createProxyMiddleware(filter, {
target: process.env.VITE_AXIOS_TARGET,
changeOrigin: false,
pathRewrite: (path) => path,
}),
);
},
});
export default ({ mode }: ConfigEnv) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
plugins: [
vuePlugin(),
{
...eslintPlugin({
failOnWarning: false,
failOnError: false,
}),
apply: 'serve',
enforce: 'post',
},
vuetify({ autoImport: true }),
axiosRedirectConfig(),
],
resolve: {
// alias: {
// @ts-ignore
// '~': fileURLToPath(new URL('./node_modules', import.meta.url)),
// @ts-ignore
// '@': fileURLToPath(new URL('./vue', import.meta.url)),
// 'vue': 'vue/dist/vue.esm-bundler.js'
// },
extensions: [
'.js',
'.mjs',
'.ts',
'.vue',
'.json',
'.css',
],
},
server: {
port: 8080,
fs: { allow: ['..'] },
},
build: {
target: 'es2015',
sourcemap: true,
lib: {
entry: resolve(__dirname, 'vue/apps.ts'),
formats: ['umd', 'es'],
fileName: 'project-base',
name: 'project-base',
},
rollupOptions: {
external: ['@velis/dynamicforms', 'axios', 'lodash', 'pinia', 'vue', 'vue-ionicon', 'vuetify'],
output: {
exports: 'named',
globals: (id: string) => id, // all external modules are currently not aliased to anything but their own names
},
},
},
test: {
deps: { inline: ['vuetify'] },
globals: true,
environment: 'jsdom',
},
});
};