-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
49 lines (44 loc) · 1.51 KB
/
Copy pathvite.config.ts
File metadata and controls
49 lines (44 loc) · 1.51 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
import { cpSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import react from '@vitejs/plugin-react';
import type { Plugin } from 'vite';
import { defineConfig } from 'vitest/config';
const extensionSource = resolve(import.meta.dirname, 'extension');
const extensionOutput = resolve(import.meta.dirname, 'dist/extension');
function copyExtensionAssets(): Plugin {
return {
name: 'copy-extension-assets',
closeBundle() {
mkdirSync(extensionOutput, { recursive: true });
cpSync(resolve(extensionSource, 'icons'), resolve(extensionOutput, 'icons'), {
recursive: true,
});
for (const filename of ['background.js', 'THIRD_PARTY_NOTICES.txt']) {
cpSync(resolve(extensionSource, filename), resolve(extensionOutput, filename));
}
const manifest = JSON.parse(
readFileSync(resolve(extensionSource, 'manifest.json'), 'utf8'),
) as Record<string, unknown>;
manifest.version = '1.3.0';
manifest.description =
'A local-first personal workstation for organizing tabs, saved links, and builder updates.';
writeFileSync(
resolve(extensionOutput, 'manifest.json'),
`${JSON.stringify(manifest, null, 2)}\n`,
);
},
};
}
export default defineConfig({
plugins: [react(), copyExtensionAssets()],
base: './',
build: {
outDir: 'dist/extension',
emptyOutDir: true,
sourcemap: false,
},
test: {
environment: 'node',
include: ['src/**/*.test.ts'],
},
});