Skip to content

Commit

Permalink
fix: avoid loading fonts from ds to prevent slow loading of module
Browse files Browse the repository at this point in the history
* fix: avoid loading fonts from ds to prevent slow loading of module

Fonts loaded from DS bundle are slowing down a lot the loading of the modules
since the request to download the inline font is taking more than 2 seconds to response.

Restore the usage of @fontsource/roboto to load a local copy of the fonts.
Update webpack config to place the fonts where fontsource is loading them from.

* build(deps): update dependencies

 - @zextras/carbonio-ui-sdk 1.5.0


refs: SHELL-31  (#193)
  • Loading branch information
beawar authored Jan 31, 2023
1 parent 6eef7e7 commit e0621c3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
10 changes: 10 additions & 0 deletions carbonio.webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,15 @@ module.exports = (conf, pkg, options, mode) => {
]
};
conf.externals = {};
conf.module.rules = [
...conf.module.rules,
{
test: /\.(woff(2)?|ttf|eot)$/,
type: 'asset/resource',
generator: {
filename: './files/[name][ext]'
}
}
];
return conf;
};
25 changes: 18 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@types/ua-parser-js": "^0.7.36",
"@types/webpack-env": "1.16.3",
"@zextras/carbonio-ui-configs": "^0.1.11",
"@zextras/carbonio-ui-sdk": "^1.4.0",
"@zextras/carbonio-ui-sdk": "^1.5.0",
"autoprefixer": "10.4.2",
"babel-jest": "27.3.1",
"babel-loader": "8.2.3",
Expand Down Expand Up @@ -97,6 +97,7 @@
"webpack-merge": "5.8.0"
},
"dependencies": {
"@fontsource/roboto": "^4.5.7",
"@sentry/browser": "^6.17.7",
"@tinymce/tinymce-react": "^3.13.0",
"@zextras/carbonio-design-system": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/boot/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const ThemeProvider = ({ children }: ThemeProviderProps): JSX.Element =>
}, [localStorageSettings]);

return (
<UIThemeProvider extension={aggregatedExtensions} loadDefaultFont>
<UIThemeProvider extension={aggregatedExtensions}>
<ThemeCallbacksContext.Provider value={{ addExtension, setDarkReaderState }}>
<GlobalStyle baseFontSize={baseFontSize} />
{children}
Expand Down
4 changes: 4 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import './index.css';
import React, { lazy, Suspense } from 'react';
import { render } from 'react-dom';
import LoadingView from './boot/splash';
import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';
import '@fontsource/roboto/700.css';

window.addEventListener('contextmenu', (ev) => {
if (
Expand Down

0 comments on commit e0621c3

Please sign in to comment.