-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
78 lines (77 loc) · 1.91 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
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import { resolve } from 'node:path';
import dts from 'vite-plugin-dts';
import { execSync } from 'child_process';
import svgLoader from 'vite-svg-loader'
export default defineConfig({
build: {
sourcemap: true,
cssMinify: true,
minify: false,
rollupOptions: {
output: {
exports: 'named',
},
},
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, 'src/Drawer.ts'),
name: 'Drawer',
// the proper extensions will be added
fileName: 'drawer',
formats: ['iife', 'cjs', 'es', 'umd'],
},
},
plugins: [
dts({
insertTypesEntry: true,
rollupTypes: true,
},
),
svgLoader(),
{
name: 'postbuild-commands', // the name of your custom plugin. Could be anything.
closeBundle: async () => {
if (process.env.NODE_ENV !== 'test') {
console.log('Build docs...');
execSync('npm run doc:js'); // run during closeBundle hook. https://rollupjs.org/guide/en/#closebundle
console.log('Docs build !');
}
},
},
],
resolve: {
alias: {
find: '~',
replacement: resolve(__dirname, 'src'),
},
},
server: {
open: process.env.NODE_ENV !== 'test',
},
test: {
server: {
deps: {
inline: ['vitest-canvas-mock'],
},
},
setupFiles: ['./vitest.setup.ts'],
environment: 'jsdom',
threads: false,
// For this config, check https://github.com/vitest-dev/vitest/issues/740
environmentOptions: {
jsdom: {
resources: 'usable',
},
},
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/cypress/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'**/e2e/**',
],
},
});