forked from B2Bitcoin/beBOP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
48 lines (41 loc) · 1.28 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
import child_process from 'child_process';
if (!process.env.PUBLIC_VERSION) {
process.env.PUBLIC_VERSION = child_process.execSync('git rev-parse HEAD').toString().trim();
}
import 'sharp'; // Otherwise build errors with "module did not self-register"
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
import Icons from 'unplugin-icons/vite';
import { readdir, stat, writeFile, readFile, mkdir } from 'fs/promises';
async function recursiveCopy(src: string, dest: string) {
for (const file of await readdir(src)) {
if (file === '.' || file === '..') {
continue;
}
const isDir = await stat(`${src}/${file}`).then((s) => s.isDirectory());
if (isDir) {
await recursiveCopy(`${src}/${file}`, `${dest}/${file}`);
} else {
await mkdir(dest, { recursive: true });
await writeFile(`${dest}/${file}`, await readFile(`${src}/${file}`));
}
}
}
await recursiveCopy('node_modules/tinymce', 'static/tinymce');
export default defineConfig(({ command }) => {
if (command === 'serve') {
// Set ORIGIN to http://localhost:5173 for local development
process.env.ORIGIN = 'http://localhost:5173';
}
return {
plugins: [
sveltekit(),
Icons({
compiler: 'svelte'
})
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
};
});