@aleph-alpha/config-css 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +696 -724
- package/package.json +1 -1
- package/src/index.ts +5 -5
- package/src/presetWebFontsAlephAlpha.ts +14 -7
- package/tsconfig.json +4 -1
- package/vite.config.ts +12 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { definePreset, Preset, presetTypography, presetWind } from 'unocss';
|
|
|
2
2
|
import { presetAnimations } from 'unocss-preset-animations';
|
|
3
3
|
import presetTheme from 'unocss-preset-theme';
|
|
4
4
|
import presetLegacyCompat from '@unocss/preset-legacy-compat';
|
|
5
|
-
import boxShadowsSet from '
|
|
6
|
-
import darkModeSet from '
|
|
7
|
-
import lightModeSet from '
|
|
8
|
-
import spacingsSet from '
|
|
9
|
-
import typographySet from '
|
|
5
|
+
import boxShadowsSet from '#sd-output/box-shadows.json';
|
|
6
|
+
import darkModeSet from '#sd-output/dark-mode.json';
|
|
7
|
+
import lightModeSet from '#sd-output/light-mode.json';
|
|
8
|
+
import spacingsSet from '#sd-output/spacings.json';
|
|
9
|
+
import typographySet from '#sd-output/typography.json';
|
|
10
10
|
import { presetWebFontsAlephAlpha } from './presetWebFontsAlephAlpha';
|
|
11
11
|
|
|
12
12
|
type Theme = {
|
|
@@ -12,11 +12,21 @@ import { inter500 } from './assets/fonts/inter500.woff2';
|
|
|
12
12
|
import { inter600 } from './assets/fonts/inter600.woff2';
|
|
13
13
|
import { inter700 } from './assets/fonts/inter700.woff2';
|
|
14
14
|
|
|
15
|
-
const LEGACY_DATA_URI_PREFIX = 'data:@file/octet-stream;base64,';
|
|
16
|
-
|
|
17
15
|
const normalizeEmbeddedFontDataUri = (fontDataUri: string, mimeType = 'font/woff2') => {
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const normalizedUri = fontDataUri.trim();
|
|
17
|
+
const legacyPrefixes = [
|
|
18
|
+
'data:@file/octet-stream;base64,',
|
|
19
|
+
'data:@file/binary;base64,',
|
|
20
|
+
'data:%40file/octet-stream;base64,',
|
|
21
|
+
'data:%40file/binary;base64,',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const matchedPrefix = legacyPrefixes.find((prefix) => normalizedUri.startsWith(prefix));
|
|
25
|
+
if (matchedPrefix) {
|
|
26
|
+
return `data:${mimeType};base64,${normalizedUri.slice(matchedPrefix.length)}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return normalizedUri;
|
|
20
30
|
};
|
|
21
31
|
|
|
22
32
|
export const presetWebFontsAlephAlpha = (): Preset => ({
|
|
@@ -46,9 +56,6 @@ export const presetWebFontsAlephAlpha = (): Preset => ({
|
|
|
46
56
|
const inter700Src = normalizeEmbeddedFontDataUri(inter700);
|
|
47
57
|
|
|
48
58
|
return `
|
|
49
|
-
:root {
|
|
50
|
-
--custom-font-family: Raleway;
|
|
51
|
-
}
|
|
52
59
|
|
|
53
60
|
/* Raleway fonts (legacy support) */
|
|
54
61
|
@font-face {
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
1
3
|
import { defineConfig } from 'vite';
|
|
2
4
|
import dts from 'vite-plugin-dts';
|
|
3
5
|
|
|
6
|
+
const dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
|
|
4
8
|
export default defineConfig({
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'#sd-output': resolve(dirname, 'sd-output'),
|
|
12
|
+
},
|
|
13
|
+
},
|
|
5
14
|
build: {
|
|
6
15
|
lib: {
|
|
7
16
|
entry: './src/index.ts',
|
|
@@ -12,5 +21,7 @@ export default defineConfig({
|
|
|
12
21
|
external: ['unocss', 'unocss-preset-theme', 'unocss/preset-uno'],
|
|
13
22
|
},
|
|
14
23
|
},
|
|
15
|
-
|
|
24
|
+
// Use tsconfig `paths` for token JSON (not `../sd-output/`) so `rollupTypes` + API
|
|
25
|
+
// Extractor do not fail (see vite-plugin-dts FAQ: baseUrl + non-standard imports).
|
|
26
|
+
plugins: [dts({ rollupTypes: true, tsconfigPath: './tsconfig.json' })],
|
|
16
27
|
});
|