-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
74 lines (71 loc) · 2.01 KB
/
vite.config.ts
File metadata and controls
74 lines (71 loc) · 2.01 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
import fs from 'node:fs';
import { createRequire } from 'node:module';
import path from 'path';
import react from '@vitejs/plugin-react';
import tailwindcss from '@tailwindcss/vite';
import { normalizePath } from 'vite';
import { defineConfig } from 'vitest/config';
import { viteStaticCopy } from 'vite-plugin-static-copy';
const packageJson = JSON.parse(
fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8')
) as { version?: string };
const appVersion = packageJson.version ?? '0.0.0';
const require = createRequire(import.meta.url);
const pdfjsDistPath = path.dirname(require.resolve('pdfjs-dist/package.json'));
const pdfjsCMapsDir = normalizePath(path.join(pdfjsDistPath, 'cmaps'));
const pdfjsStandardFontsDir = normalizePath(path.join(pdfjsDistPath, 'standard_fonts'));
export default defineConfig({
// ★ GitHub Pages 用のベースパス(リポジトリ名と完全一致)
base: '/CutMark-PDF/',
server: {
port: 3000,
host: '0.0.0.0',
},
plugins: [
react(),
tailwindcss(),
viteStaticCopy({
targets: [
{
src: normalizePath(path.join(pdfjsCMapsDir, '*')),
dest: 'cmaps',
rename: { stripBase: true },
},
{
src: normalizePath(path.join(pdfjsStandardFontsDir, '*')),
dest: 'standard_fonts',
rename: { stripBase: true },
},
],
}),
],
define: {
// package.json の version をアプリに注入
__APP_VERSION__: JSON.stringify(appVersion),
},
resolve: {
alias: {
'@': path.resolve(__dirname, '.'),
},
},
test: {
environment: 'jsdom',
setupFiles: ['./test/setup.ts'],
css: false,
coverage: {
provider: 'v8',
reporter: ['text', 'html'],
include: [
'adapters/**/*.ts',
'application/**/*.ts',
'components/**/*.tsx',
'domain/**/*.ts',
'hooks/**/*.ts',
'hooks/**/*.tsx',
'repositories/**/*.ts',
'services/**/*.ts',
'utils/**/*.ts',
],
},
},
});