This repository has been archived by the owner on Nov 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
103 lines (101 loc) · 2.38 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
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
import process from 'node:process';
import {defineConfig} from 'vite';
import prefresh from '@prefresh/vite';
import strip from '@rollup/plugin-strip';
import {defaultImport} from 'default-import';
import inspect from 'vite-plugin-inspect';
import environment from 'vite-plugin-environment';
import preactDebug from './vite/preact-debug.js';
import typedCssModules from './vite/typed-css-modules.js';
import updateLicenses from './vite/licenses.js';
const ensureTrailingSlash = (url: string) =>
url.endsWith('/') ? url : url + '/';
export default defineConfig(({command}) => ({
base: ensureTrailingSlash(
process.env.RTE_BASE_URL ?? process.env.BASE_URL ?? '/',
),
cacheDir: 'node_modules/.cache/vite',
css: {
devSourcemap: true,
modules: {
generateScopedName: '[local]_[sha256:hash:hex:8]',
localsConvention: 'dashesOnly',
},
},
esbuild: {
jsx: 'automatic',
jsxImportSource: 'preact',
jsxDev: command !== 'build',
minifyIdentifiers: command === 'build',
keepNames: command !== 'build',
treeShaking: true,
},
build: {
target: ['firefox103', 'chrome104'],
outDir: 'build',
rollupOptions: {
input: ['index.html'],
},
},
server: {
port: 12_345,
strictPort: true,
cors: false,
},
preview: {
port: 12_345,
strictPort: true,
cors: false,
},
plugins: [
environment(['RTE_TREE_URL', 'RTE_BLOB_URL'], {
defineOn: 'import.meta.env',
}),
defaultImport(inspect)({
build: false,
outputDir: 'node_modules/.cache/vite-inspect',
}),
preactDebug,
command === 'build' &&
defaultImport(strip)({
functions: [
'performance.mark',
'performance.measure',
'console.debug',
],
include: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
}),
prefresh(),
typedCssModules,
updateLicenses,
],
define: {
/* eslint-disable @typescript-eslint/naming-convention */
'import.meta.vitest': 'undefined',
/* eslint-enable @typescript-eslint/naming-convention */
},
test: {
environment: 'jsdom',
css: true,
coverage: {
provider: 'v8',
all: true,
skipFull: true,
reporter: 'lcov',
src: ['src'],
exclude: [
'**/*.test.*',
'**/*.d.ts',
'src/license-types.ts',
'src/components/icons/gamepad/face-button/types.ts',
'src/composition/test-renderer.ts',
'src/composition/event.ts',
],
},
cache: {
dir: 'node_modules/.cache/vitest',
},
setupFiles: 'src/setup.ts',
mockReset: true,
},
}));