-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.js
70 lines (68 loc) · 2.08 KB
/
vite.config.js
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
import { sveltekit } from '@sveltejs/kit/vite';
import svg from '@poppanator/sveltekit-svg';
import basicSsl from '@vitejs/plugin-basic-ssl';
import { defineConfig, loadEnv } from 'vite';
import { WorkerBuildPlugin } from './vite.worker-build-plugin';
import { lezer } from '@lezer/generator/rollup';
const config = ({ mode }) => {
const viteEnvVars = loadEnv(mode, process.cwd());
return defineConfig({
build: {
minify: true,
},
css: {
devSourcemap: true,
},
plugins: [
...(viteEnvVars.VITE_HTTPS === 'true' ? [basicSsl()] : []),
lezer(),
sveltekit(),
svg({
svgoOptions: {
multipass: true,
plugins: [
{
name: 'preset-default',
// by default svgo removes the viewBox which prevents svg icons from scaling
// not a good idea! https://github.com/svg/svgo/pull/1461
params: { overrides: { removeViewBox: false } },
},
{
name: 'addClassesToSVGElement',
params: {
classNames: ['st-icon'],
},
},
],
},
}),
WorkerBuildPlugin(
['./src/workers/customTS.worker.ts', './node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js'],
{
log: true,
},
),
],
server: {
host: viteEnvVars.VITE_HOST ?? 'localhost',
},
test: {
alias: [{ find: /^svelte$/, replacement: 'svelte/internal' }], // https://github.com/vitest-dev/vitest/issues/2834
coverage: {
exclude: ['src/routes/*'],
include: ['src/**/*'],
reporter: ['text', 'json', 'html'],
reportsDirectory: './unit-test-results/coverage',
},
environment: 'jsdom',
include: ['./src/**/*.test.ts'],
outputFile: {
html: 'unit-test-results/html-results/index.html',
json: 'unit-test-results/json-results.json',
junit: 'unit-test-results/junit-results.xml',
},
reporters: ['verbose', 'json', 'junit', 'html'],
},
});
};
export default config;