-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
94 lines (89 loc) · 2.82 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
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import dts from 'vite-plugin-dts';
import { resolve } from 'node:path';
import { optimizeLodashImports } from "@optimize-lodash/rollup-plugin";
const res = ( path: string ) => resolve( __dirname, path );
// https://vitejs.dev/config/
export default defineConfig( ( { command, mode } ) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv( mode, process.cwd()/*, ''*/ );
const base = env.VITE_API_BASE || 'http://localhost';
const apiURL = new URL( base );
return {
resolve: {
alias: {
'@': res( 'src' ),
'@dmidz/tickschart': res( 'dist' ),
'@public': res( 'public/tickschart' ),
},
// preserveSymlinks: true,
},
plugins: [
vue(),
dts( {// gently generates *.d.ts files at build :)
pathsToAliases: false,
rollupTypes: true,
include: [ 'src/lib/**/*.ts', 'src/types.d.ts' ],
} ),
optimizeLodashImports(),
],
build: {
copyPublicDir: false,
lib: {
entry: {
index: res( 'src/lib/index.ts' ),
},
name: 'TicksChart',
formats: [ 'es' ],
// fileName: 'tickschart',
},
rollupOptions: {
external: [ 'vue' ],// make sure to externalize deps that shouldn't be bundled into your library
output: {
globals: {// Provide global variables to use in the UMD build for externalized deps
vue: 'Vue',
},
},
},
},
test: {
environment: 'happy-dom',
},
server: {
host: apiURL.hostname,
proxy: {// check https://vite.dev/config/server-options.html#server-proxy
'/api': {
target: base,
changeOrigin: true,
rewrite: ( path ) => path.replace( /^\/api/, '' ),
secure: false,
// configure: ( proxy, _options ) => {
// proxy.on( 'error', ( err, _req, _res ) => {
// console.log( 'proxy error', err );
// } );
// proxy.on( 'proxyReq', ( proxyReq, req, _res ) => {
// console.log( 'Sending Request to the Target:', req.method, req.url );
// } );
// proxy.on( 'proxyRes', ( proxyRes, req, _res ) => {
// console.log( 'Received Response from the Target:', { ur: req.url, headers: proxyRes.headers } );
// } );
// },
},
// '/socket.io': {
// target: base,
// changeOrigin: true,
// ws: true
// },
}
},
// optimizeDeps: {
// esbuildOptions: {
// tsconfig: 'tsconfig.json'
// }
// },
}
} )
;