-
Notifications
You must be signed in to change notification settings - Fork 49
/
vite.config.js
92 lines (90 loc) · 3.36 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { sveltekit } from '@sveltejs/kit/vite';
import Unocss from 'unocss/vite';
import { presetTypography, presetIcons, presetUno } from 'unocss';
import extractorSvelte from '@unocss/extractor-svelte';
import { presetScrollbar } from 'unocss-preset-scrollbar';
import transformerDirective from '@unocss/transformer-directives';
import transformerVariantGroup from '@unocss/transformer-variant-group';
import transformerCompileClass from '@unocss/transformer-compile-class';
import { imagetools } from 'vite-imagetools';
import path from 'path';
import { partytownVite } from '@builder.io/partytown/utils';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
const pathMainPkg = fileURLToPath(new URL('package.json', import.meta.url));
const jsonMainPkg = readFileSync(pathMainPkg, 'utf8');
const pathQWERPkg = fileURLToPath(new URL('QWER/package.json', import.meta.url));
const jsonQWERPkg = readFileSync(pathQWERPkg, 'utf8');
const mainPkg = JSON.parse(jsonMainPkg);
const qwerPkg = JSON.parse(jsonQWERPkg);
const outputFolderPath = Object.keys(process.env).some((key) => key.includes('VERCEL'))
? '.vercel/output/static'
: Object.keys(process.env).some((key) => key.includes('NETLIFY'))
? 'build'
: 'static';
/** @type {import('vite').UserConfig} */
export default defineConfig({
mode: process.env.MODE || 'production',
envPrefix: 'QWER_',
define: {
__VERSION_MAIN__: mainPkg,
__VERSION_QWER__: qwerPkg,
},
plugins: [
Unocss({
extractors: [extractorSvelte()],
presets: [
presetUno(),
presetScrollbar(),
presetIcons(),
presetTypography({
cssExtend: {
':not(pre) > code::before,:not(pre) > code::after': {
content: '',
},
pre: {
'border-radius': 0,
padding: 0,
margin: 0,
},
},
}),
],
transformers: [transformerDirective(), transformerVariantGroup(), transformerCompileClass()],
shortcuts: [
{
'title-link':
'bg-gradient-to-t from-orange-500 to-orange-500 bg-no-repeat [background-position:0_88%] [background-size:0%_0.1em] focus:![background-size:100%_100%] hover:![background-size:100%_100%] group-hover:[background-size:100%_0.1em] motion-safe:transition-all motion-safe:duration-200',
},
[
/^title-link-(.*)-(.*)-(.*)-(.*)$/,
([, f, fc, t, tc]) =>
`bg-gradient-to-t from-${f}-${fc} to-${t}-${tc} bg-no-repeat [background-position:0_88%] [background-size:0%_0.15em] focus:![background-size:100%_100%] hover:![background-size:100%_100%] group-hover:[background-size:100%_0.15em] motion-safe:transition-all motion-safe:duration-300`,
],
],
}),
imagetools(),
sveltekit(),
partytownVite({
dest: path.join(__dirname, outputFolderPath, '~partytown'),
}),
],
resolve: {
alias: {
$QWER: path.resolve('.', 'QWER'),
$generated: path.resolve('.', 'src/generated'),
$stores: path.resolve('.', 'src/lib/stores'),
$i18n: path.resolve('.', 'src/i18n'),
$config: path.resolve('.', 'user/config'),
$assets: path.resolve('.', 'user/assets'),
$custom: path.resolve('.', 'user/custom'),
$static: path.resolve('.', 'static'),
},
},
server: {
fs: {
allow: ['..'],
},
},
});