-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
94 lines (89 loc) · 2.45 KB
/
vite.config.js
File metadata and controls
94 lines (89 loc) · 2.45 KB
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
import {defineConfig} from 'vite';
import {playwright} from '@vitest/browser-playwright';
import {globSync} from 'tinyglobby';
import copy from 'rollup-plugin-copy';
import totalBundlesize from '@blockquote/rollup-plugin-total-bundlesize';
const OUT_DIR = 'dev';
const ENTRIES_DIR = 'demo';
const ENTRIES_GLOB = [`${ENTRIES_DIR}/**/*.js`];
const copyConfig = {
targets: [
{
src: [`${ENTRIES_DIR}/**/*.*`, `!${ENTRIES_GLOB}`],
dest: OUT_DIR,
},
],
hook: 'writeBundle',
};
// https://github.com/vitejs/vite/discussions/1736#discussioncomment-5126923
const entries = Object.fromEntries(
globSync(ENTRIES_GLOB).map((file) => {
const [key] = file.match(new RegExp(`(?<=${ENTRIES_DIR}/).*`)) || [];
return [key?.replace(/\.[^.]*$/, ''), file];
})
);
// https://vitejs.dev/config/
// https://vite-rollup-plugins.patak.dev/
// https://github.com/vitest-dev/vitest/commit/78b62ffe#diff-d3e264f3679867e205ed7eeb7622aa3b62bb0c4b1a4aa5a5983cb3aa118fcf3c
export default defineConfig(({command}) => ({
test: {
onConsoleLog(log, type) {
if (type === 'stderr' && log.includes('in dev mode')) {
return false;
}
},
include: ['test/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
forceRerunTriggers: ['**/src/**/*.scss*'],
browser: {
enabled: true,
headless: true,
provider: playwright(),
screenshotFailures: false,
instances: [
{
browser: 'chromium',
provider: playwright({
launchOptions: {
devtools: true,
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu'],
},
}),
},
],
},
coverage: {
provider: 'v8',
reportsDirectory: 'test/coverage/',
reporter: ['lcov', 'json', 'text-summary'],
enabled: true,
thresholds: {
statements: 80,
branches: 80,
functions: 80,
lines: 80,
},
include: ['**/src/**/*'],
exclude: ['**/src/**/index.*', '**/src/styles/', '**/src/utils.*'],
},
},
plugins: [copy(copyConfig), totalBundlesize()],
optimizeDeps: {
exclude: ['lit', 'lit-html'],
},
build: {
outDir: OUT_DIR,
rolldownOptions: {
preserveEntrySignatures: 'exports-only',
transform: {
target: ['chrome71'],
},
input: entries,
output: {
dir: OUT_DIR,
entryFileNames: '[name].js',
format: 'es',
},
treeshake: true,
},
},
}));