-
Notifications
You must be signed in to change notification settings - Fork 100
/
vite.config.ts
109 lines (97 loc) · 2.5 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
104
105
106
107
108
109
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
import { resolve } from 'path';
import { createRequire } from 'module';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
const require = createRequire( import.meta.url );
const pkg = require( './package.json' );
const REACT_VERSION = Number( process.env.REACT_VERSION ) || 18;
export default defineConfig( {
plugins: [
react( { jsxRuntime: 'classic' } )
],
publicDir: false,
build: {
minify: false,
sourcemap: true,
target: 'es2019',
// https://vitejs.dev/guide/build#library-mode
lib: {
entry: resolve( __dirname, 'src/index.ts' ),
name: 'CKEDITOR_REACT',
fileName: 'index'
},
rollupOptions: {
external: Object.keys( {
...pkg.dependencies,
...pkg.peerDependencies
} ),
output: {
globals: {
'react': 'React',
'prop-types': 'PropTypes',
'@ckeditor/ckeditor5-integrations-common': 'CKEDITOR_INTEGRATIONS_COMMON'
}
}
}
},
// https://vitest.dev/config/
test: {
setupFiles: [ './vitest-setup.ts' ],
include: [
'tests/**/*.test.[j|t]sx'
],
sequence: {
shuffle: true
},
coverage: {
provider: 'istanbul',
include: [ 'src/*' ],
exclude: [ 'src/demos' ],
thresholds: {
100: true
},
reporter: [
'text-summary',
'text',
'html',
'lcovonly',
'json'
]
},
browser: {
enabled: true,
headless: true,
provider: 'webdriverio',
name: 'chrome',
screenshotFailures: false
}
},
/**
* Code needed to run the demos using different React versions.
*
* Notice that in `package.json`, aside from the regular `react` and `react-dom` dependencies,
* there are also:
*
* - `react16` and `react16-dom`,
* - `react18` and `react18-dom`,
* - `react19` and `react19-dom`.
*
* These point to the respective React versions, and are used to test the demos with different
* React versions, depending on the `REACT_VERSION` environment variable.
*/
resolve: {
alias: {
'react': resolve( __dirname, `node_modules/react${ REACT_VERSION }` ),
'react-dom/client': resolve( __dirname, `node_modules/react${ REACT_VERSION }-dom${ REACT_VERSION <= 17 ? '' : '/client' }` ),
'react-dom': resolve( __dirname, `node_modules/react${ REACT_VERSION }-dom` )
}
},
define: {
__REACT_VERSION__: REACT_VERSION,
__REACT_INTEGRATION_VERSION__: JSON.stringify( pkg.version )
}
} );