-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
35 lines (30 loc) · 989 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
35
/* eslint-disable import/no-extraneous-dependencies */
import path from 'path';
import reactRefresh from '@vitejs/plugin-react-refresh';
import { Alias, defineConfig } from 'vite';
import * as tsconfig from './tsconfig.paths.json';
function readAliasFromTsConfig(): Alias[] {
const pathReplaceRegex = new RegExp(/\/\*$/, '');
return Object.entries(tsconfig.compilerOptions.paths).reduce((aliases, [fromPaths, toPaths]) => {
const find = fromPaths.replace(pathReplaceRegex, '');
const toPath = toPaths[0].replace(pathReplaceRegex, '');
const replacement = path.resolve(__dirname, toPath);
aliases.push({ find, replacement });
return aliases;
}, [] as Alias[]);
}
export default defineConfig({
plugins: [reactRefresh()],
resolve: {
alias: readAliasFromTsConfig(),
},
css: { modules: { localsConvention: 'camelCase' } },
server: {
proxy: {
'/hliu/liu-uni.js': 'https://boshiamy.com',
},
},
build: {
outDir: 'build',
},
});