-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
70 lines (64 loc) · 1.74 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
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { lilconfig } from 'lilconfig';
import { createRequire } from 'module';
import { register } from 'ts-node';
import { fileURLToPath } from 'url';
import path from 'path';
const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Register ts-node with proper ESM settings
register({
esm: true,
experimentalSpecifierResolution: 'node',
moduleTypes: {
"**/*.ts": "esm"
}
});
async function loadGitInlineConfig() {
try {
const explorer = lilconfig('gitinline', {
searchPlaces: [
'gitinline.config.ts',
'gitinline.config.js',
'.gitinlinerc',
'.gitinlinerc.json',
'package.json'
],
loaders: {
'.ts': async (filepath) => {
// For TypeScript files, use dynamic import
const { pathToFileURL } = await import('url');
const module = await import(pathToFileURL(filepath).href);
return module.default || module;
}
}
});
const result = await explorer.search();
return result?.config || {
owner: 'teamleaderleo',
repo: 'git-inline'
};
} catch (error) {
console.warn('Error in loadGitInlineConfig:', error);
return {
owner: 'teamleaderleo',
repo: 'git-inline'
};
}
}
export default defineConfig(async () => {
const gitInlineConfig = await loadGitInlineConfig();
return {
plugins: [react()],
root: './demo',
define: {
'__GIT_INLINE_CONFIG__': JSON.stringify(gitInlineConfig)
},
// Add proper resolution for TypeScript files
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
}
};
});