-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathvite.config.ts
More file actions
executable file
·115 lines (111 loc) · 3.84 KB
/
Copy pathvite.config.ts
File metadata and controls
executable file
·115 lines (111 loc) · 3.84 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import tailwindcss from '@tailwindcss/postcss';
import react from '@vitejs/plugin-react';
import path from 'path';
import topLevelAwait from 'vite-plugin-top-level-await';
import wasm from 'vite-plugin-wasm';
import { defineConfig } from 'vite';
import { execSync } from 'child_process';
import IstanbulPlugin from './src/packages/vite-plugin-istanbul/index';
import { commonFilesPlugin } from './src/packages/vite-plugin-common-files';
import { unusedFilesPlugin } from './src/packages/vite-plugin-detect-unused-files/detect-unused-files';
function getGitCommitHash() {
try {
return execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();
} catch {
return 'unknown';
}
}
const base = process.env.USE_RELATIVE_BASE === 'true' ? './' : '/';
export default defineConfig({
base,
define: {
__PROJECT_COMMIT_HASH__: JSON.stringify(getGitCommitHash()),
},
build: {
target: 'es2020',
sourcemap: true,
},
resolve: {
alias: {
'@': path.join(__dirname, './src'),
vscf: path.join(__dirname, './src/packages/vscf'),
vs: path.join(__dirname, './src/packages/vscf/internal'),
},
},
plugins: [
topLevelAwait({
promiseExportName: '__tla',
promiseImportName: (i) => `__tla_${i}`,
}),
react(),
wasm(),
IstanbulPlugin({
enabled: process.env.VITE_COVERAGE === 'true',
exclude: ['**/node_modules/**', '**/vscf/**'],
include: ['**/*.ts', '**/*.tsx'],
}),
unusedFilesPlugin({
exclude: [
'src/packages/vscf/**',
'src/packages/cloud/**',
'src/packages/eslint-plugin/**',
'src/packages/vite-plugin-*/**',
'src/packages/server-sdk/**',
'src/packages/docs/**',
'src/third-party/**',
'src/electron/**',
'src/server/**',
'src/cli/**',
// shared with the electron main process and the CLI; covered directly
// by packages/unit-test rather than through the web bundle
'src/base/common/cliApproval/**',
'src/core/time/getTimeStampFromDateStr.ts',
'src/core/time/isStartOfDay.ts',
'**/*.d.ts',
],
}),
commonFilesPlugin({
entries: ['src/desktop/main.tsx', 'src/mobile/main.tsx'],
exclude: [
'src/nls.ts',
'src/core/**',
'src/packages/vscf/**',
'src/services/**/*.ts',
'src/packages/cloud/**',
'src/packages/server-sdk/**',
'src/base/common/**',
'src/hooks/**',
'src/plugins/**',
'src/utils/dnd/**',
'src/locales/**',
'src/base/browser/**',
'src/testIds.ts',
'src/components/icons/index.ts',
'src/components/GlobalContext/GlobalContext.tsx',
'src/components/icons/ProjectStatusBox.tsx',
// Deliberately shared so task/project state visuals stay identical across platforms.
'src/components/todo/ItemStatusIcon.tsx',
'src/components/todo/itemStatusVisual.ts',
'src/styles/item-status.css',
],
validate: (files) => {
console.log('\n┌─────────────────────────────────────────────────┐');
console.log(`│ Common files between desktop and mobile: ${String(files.length).padEnd(5)} │`);
console.log('└─────────────────────────────────────────────────┘');
if (files.length > 0) {
files.forEach((file, index) => {
const prefix = index === files.length - 1 ? '└──' : '├──';
console.log(`${prefix} ${file}`);
});
console.log('');
throw new Error('Found common files between desktop and mobile!');
}
},
}),
],
css: {
postcss: {
plugins: [tailwindcss()],
},
},
});