-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
68 lines (65 loc) · 1.86 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
/// <reference types="vitest" />
/// <reference types="vite/client" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import * as Path from 'path';
import { resolve } from 'path';
import mkcert from 'vite-plugin-mkcert';
import { createHash } from 'crypto';
import pluginRewriteAll from 'vite-plugin-rewrite-all';
import ViteCSSExportPlugin from 'vite-plugin-css-export';
const srcPath = resolve(__dirname, 'src');
const testsPath = resolve(__dirname, 'tests');
export default defineConfig({
base: '/2048/',
plugins: [react(), mkcert(), pluginRewriteAll(), ViteCSSExportPlugin()],
server: {
port: 3000,
host: 'localhost',
https: true
},
build: {
target: 'esnext'
},
preview: {
port: 3000,
host: 'localhost'
},
resolve: {
alias: {
src: srcPath,
'@': srcPath,
'@tests': testsPath
}
},
css: {
modules: {
generateScopedName: (name, filename) => {
const moduleName = Path.parse(filename).name.split('.')[0];
const hash = createHash('md5').update(filename).digest('hex').slice(0, 5);
return `${moduleName}__${name}__${hash}`;
},
localsConvention: 'camelCaseOnly'
}
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['tests/setup.ts'],
reporters: ['junit', 'basic'],
outputFile: './tests/test-results.xml',
restoreMocks: true,
coverage: {
provider: 'istanbul',
all: true,
reportsDirectory: './tests/coverage',
reporter: ['text', 'lcov'],
include: ['src/**/*.{ts,tsx}']
},
css: {
modules: {
classNameStrategy: 'non-scoped'
}
}
}
});