Skip to content

Commit

Permalink
fix(SLB-222): build fontlist during prep
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Apr 19, 2024
1 parent 6d9d3b7 commit 972d4e0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion apps/website/gatsby-ssr.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Locale } from '@custom/schema';
import { fonts } from '@custom/ui/preloaded-fonts';
import { GatsbySSR } from 'gatsby';
import React from 'react';

import fonts from './node_modules/@custom/ui/build/preloaded-fonts.json';

export const onRenderBody: GatsbySSR['onRenderBody'] = ({
setHtmlAttributes,
pathname,
Expand Down
7 changes: 1 addition & 6 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,19 @@
],
"./styles.css": [
"./build/styles.css"
],
"./preloaded-fonts": [
"./build/preloaded-fonts.js"
]
},
"typesVersions": {
"*": {
"routes/*": [
"build/components/Routes/*.d.ts"
],
"preloaded-fonts": [
"build/preloaded-fonts.d.ts"
]
}
},
"scripts": {
"prep:types": "tsc --emitDeclarationOnly",
"prep:scripts": "swc ./src -d ./build",
"prep:fonts": "node preloaded-fonts.js",
"prep:styles": "NODE_ENV=production pnpm postcss src/tailwind.css -o build/styles.css",
"prep:iframe": "NODE_ENV=production pnpm postcss src/iframe.css -o build/iframe.css",
"prep:gutenberg": "NODE_ENV=production PREFIX=gutenberg pnpm postcss src/tailwind.css -o build/gutenberg.css",
Expand Down
10 changes: 10 additions & 0 deletions packages/ui/preloaded-fonts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { readdirSync, writeFileSync } from 'fs';

writeFileSync(
'build/preloaded-fonts.json',
JSON.stringify(
readdirSync(`static/public/fonts/preload`).map((font) => {
return `/fonts/preload/${font}`;
}),
),
);
7 changes: 0 additions & 7 deletions packages/ui/src/preloaded-fonts.ts

This file was deleted.

5 changes: 5 additions & 0 deletions packages/ui/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"$schema": "https://turborepo.org/schema.json",
"extends": ["//"],
"pipeline": {
"prep:fonts": {
"inputs": ["static/public/fonts/preload/**"],
"outputs": ["build/preloaded-fonts.json"]
},
"prep:scripts": {
"dependsOn": ["^prep"],
"inputs": [
Expand Down Expand Up @@ -48,6 +52,7 @@
},
"prep": {
"dependsOn": [
"prep:fonts",
"prep:types",
"prep:scripts",
"prep:styles",
Expand Down

0 comments on commit 972d4e0

Please sign in to comment.