@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aleph-alpha/config-css",
3
3
  "license": "Apache-2.0",
4
- "version": "0.21.1",
4
+ "version": "0.22.0",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "prettier": "@aleph-alpha/prettier-config-frontend",
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 '../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';
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
- if (!fontDataUri.startsWith(LEGACY_DATA_URI_PREFIX)) return fontDataUri;
19
- return `data:${mimeType};base64,${fontDataUri.slice(LEGACY_DATA_URI_PREFIX.length)}`;
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
@@ -7,7 +7,10 @@
7
7
  "lib": ["ES2021.String"],
8
8
  "moduleResolution": "node",
9
9
  "resolveJsonModule": true,
10
- "skipLibCheck": true
10
+ "skipLibCheck": true,
11
+ "paths": {
12
+ "#sd-output/*": ["sd-output/*"]
13
+ }
11
14
  },
12
15
  "exclude": ["node_modules"],
13
16
  "include": ["src/**/*.ts"]
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
- plugins: [dts({ rollupTypes: true })],
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
  });