Skip to content

Instantly share code, notes, and snippets.

@avorona
Last active August 1, 2018 14:33
Show Gist options
  • Save avorona/3a67e7f3613bea5fd3dd8f52bd24bdd3 to your computer and use it in GitHub Desktop.
Save avorona/3a67e7f3613bea5fd3dd8f52bd24bdd3 to your computer and use it in GitHub Desktop.
How to add custom font to the Storybook
.storybook
--webpack.config.js
app
--package.json
----assets
------fonts
--------Lato-Regular.woff
--------Lato-Regular.woff2
{
"scripts": {
"storybook": "start-storybook -p 9001 -c .storybook watch-css -s ./app"
}
}
<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>
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