-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
34 lines (28 loc) · 976 Bytes
/
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
import { defineConfig, AliasOptions } from 'vite';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import * as tsconfig from './tsconfig.json';
// @src: https://github.com/Melvin-Abraham/Google-Assistant-Unofficial-Desktop-Client/blob/next/vite.config.ts#L9
// Resolve path aliases from `tsconfig.json`
const tsconfigAliases = tsconfig.compilerOptions.paths;
const aliasOptions: AliasOptions = {};
Object.entries(tsconfigAliases).forEach((aliasEntry) => {
const [_alias, paths] = aliasEntry;
// Strip glob from the end of path
// Ex: "path/*" -> "path"
const pathEndGlobRegex = /[/*]*$/;
const alias = _alias.replace(pathEndGlobRegex, '');
const resolutionPath = resolve(
__dirname,
paths[0].replace(pathEndGlobRegex, ''),
);
aliasOptions[alias] = resolutionPath;
});
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: aliasOptions,
},
base: '/todomatic/',
});