Last active
August 1, 2018 14:33
-
-
Save avorona/3a67e7f3613bea5fd3dd8f52bd24bdd3 to your computer and use it in GitHub Desktop.
How to add custom font to the Storybook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .storybook | |
| --webpack.config.js | |
| app | |
| --package.json | |
| ----assets | |
| ------fonts | |
| --------Lato-Regular.woff | |
| --------Lato-Regular.woff2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "scripts": { | |
| "storybook": "start-storybook -p 9001 -c .storybook watch-css -s ./app" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style type="text/css"> | |
| // Lato as example | |
| @font-face { | |
| font-family: 'Lato'; | |
| src: url('assets/fonts/Lato-Regular.woff2') format('woff2'), | |
| url('assets/fonts/Lato-Regular.woff') format('woff'); | |
| font-weight: normal; | |
| font-style: normal; | |
| } | |
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| module.exports = (baseConfig, env, defaultConfig) => { | |
| // Extend defaultConfig . | |
| defaultConfig.resolve.modules.push('app'); | |
| defaultConfig.module.rules.push({ | |
| test: /\.(png|woff|woff2|eot|ttf|svg)$/, | |
| loaders: ['file-loader'], | |
| include: path.resolve(__dirname, '../'), | |
| }); | |
| return defaultConfig; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment