Skip to content

Commit

Permalink
fix: change how the fonts are imported and bundled
Browse files Browse the repository at this point in the history
* fix: change how the fonts are imported and bundled

Import fonts directly so that rollup is able to recognize them
and bundle with the url-plugin as inline resources.
By bundling them this way, fonts are resolved and used when setting
the loadDefaultFont prop in the ThemeProvider.

Update also webpack to recognize the fonts as asset/resource for the styleguide.

Add a file transformer for jest and update the config to use it.

Remove no more used plugin from dependencies.

* docs: use default fonts for docs examples

For other components of the documentation (list, title, field description, etc)
use the sans-serif.
Define styleguide theme config in an external file to make them hot-reloadable

* build(deps): reset rollup to v2

Rollup v3 has some breaking changes which require a more in depth investigation

Use @rollup/plugin-url instead of rollup-plugin-url


refs: CDS-110 (#159)
  • Loading branch information
beawar authored Jan 17, 2023
1 parent 600d941 commit 458519c
Show file tree
Hide file tree
Showing 13 changed files with 671 additions and 1,232 deletions.
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/.eslintrc.js
/.prettierrc.js
/commitlint.config.js
/rollup.config.js
/rollup.config.mjs
/.github
/LICENSES
tsconfig.json
Expand Down
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ License: CC0-1.0

Files: src/fonts/*
Copyright: <https://github.com/googlefonts/roboto>
License: Apache-2.0
License: Apache-2.0
10 changes: 6 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default {
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['/node_modules/']
testPathIgnorePatterns: ['/node_modules/'],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand All @@ -169,9 +169,11 @@ export default {
// timers: "real",

// A map from regular expressions to paths to transformers
// "transform": {
// "^.+\\.[t|j]sx?$": "babel-jest"
// },
transform: {
'^.+\\.[t|j]sx?$': ['babel-jest', { configFile: './babel.config.js' }],
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/src/testUtils/fileTransformer.js'
}

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand Down
2 changes: 1 addition & 1 deletion lib/styleguide/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export default function Wrapper({
}: {
children?: React.ReactNode | React.ReactNode[];
}): JSX.Element {
return <ThemeProvider>{children}</ThemeProvider>;
return <ThemeProvider loadDefaultFont>{children}</ThemeProvider>;
}
Loading

0 comments on commit 458519c

Please sign in to comment.