Skip to content

Commit

Permalink
✨(fonts) allow async font loading
Browse files Browse the repository at this point in the history
Vite automatically inline assets in CSS in lib mode and this is
hardcoded in it. After multiple approaches it seems that this one
is the most trivial and easy-to-maintain one.
  • Loading branch information
NathanVss committed Mar 28, 2023
1 parent b2fd517 commit 1f0d890
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/demo/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import "@openfun/cunningham-react/fonts";
@import "@openfun/cunningham-react/icons";
@import "@openfun/cunningham-react/sass/fonts";
@import "@openfun/cunningham-react/sass/icons";
@import "@openfun/cunningham-react/style";
@import "cunningham-tokens";

Expand Down
8 changes: 5 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
},
"./style": "./dist/style.css",
"./fonts": "./dist/fonts.css",
"./icons": "./dist/icons.css"
"./icons": "./dist/icons.css",
"./sass/fonts": "./dist/sass/fonts.scss",
"./sass/icons": "./dist/sass/icons.scss"
},
"files": [
"dist/"
Expand All @@ -27,8 +29,8 @@
"lint": "eslint . 'src/**/*.{ts,tsx}'",
"dev": "yarn storybook & nodemon --watch src --ext '*' --ignore src/cunningham-tokens.ts --ignore src/cunningham-tokens.js --ignore src/cunningham-tokens.css --exec npm run build",
"build": "tsc && yarn build-theme && vite build && yarn build-fonts && yarn build-icons",
"build-fonts": "vite build -c vite.fonts.config.ts && rm -rf dist/fonts.js",
"build-icons": "vite build -c vite.icons.config.ts && rm -rf dist/icons.js",
"build-fonts": "vite build -c vite.fonts.config.ts && rm -rf dist/fonts.js && mkdir -p dist/sass && cp src/fonts.scss dist/sass/",
"build-icons": "vite build -c vite.icons.config.ts && rm -rf dist/icons.js && mkdir -p dist/sass && cp src/icons.scss dist/sass/",
"build-theme": "cunningham -o src -g css,ts,js",
"preview": "vite preview",
"test": "FORCE_COLOR=1 vitest run",
Expand Down

0 comments on commit 1f0d890

Please sign in to comment.