generated from oddbird/polyfill-template
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
vite.config.ts
74 lines (72 loc) · 2.27 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
/// <reference types="vitest" />
import { resolve } from 'path';
import { bundleStats } from 'rollup-plugin-bundle-stats';
import { defineConfig } from 'vite';
export default defineConfig({
server: {
port: 3000,
},
build: process.env.NETLIFY
? {}
: {
lib: process.env.BUILD_WPT
? // build that adds a delay variable for WPT test-runner
{
entry: resolve(__dirname, 'src/index-wpt.ts'),
name: 'CssAnchorPositioning',
formats: ['umd'],
// the proper extensions will be added
fileName: 'css-anchor-positioning-wpt',
}
: process.env.BUILD_FN
? // build that exposes the polyfill as a fn
{
entry: resolve(__dirname, 'src/index-fn.ts'),
name: 'CssAnchorPositioning',
// the proper extensions will be added
fileName: 'css-anchor-positioning-fn',
}
: // build that runs the polyfill on import
{
entry: resolve(__dirname, 'src/index.ts'),
name: 'CssAnchorPositioning',
// the proper extensions will be added
fileName: 'css-anchor-positioning',
},
emptyOutDir: !process.env.BUILD_FN,
target: 'es6',
sourcemap: true,
rollupOptions: {
external: [/source-map-js/],
// This is not needed, but silences a Rollup warning
output: {
globals: {
'source-map-js/lib/source-map-generator.js':
'sourceMapGenerator_js',
},
},
},
},
plugins: [bundleStats({ compare: false, silent: true })],
/**
* @see https://vitest.dev/config/#configuration
*/
test: {
include: ['./tests/unit/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globals: true,
environment: 'jsdom',
watch: false,
setupFiles: './tests/unit/setup.ts',
clearMocks: true,
reporters: 'dot',
coverage: {
enabled: true,
provider: 'istanbul',
reporter: ['text-summary', 'html'],
include: ['src/**/*.{js,ts}'],
exclude: ['src/index.ts', 'src/index-fn.ts', 'src/index-wpt.ts'],
skipFull: true,
all: true,
},
},
});