Storybook: How to change favicon?

Created on 18 Mar 2019  ·  2Comments  ·  Source: storybookjs/storybook

Describe the bug

We are unable to set a custom favicon for the storybook static build and development. We've tried using HtmlWebpackPlugin, setting the icon with different urls in the preview-header.html and manager-header.html having imported the 'favicon.ico' in the config.js as follows:

import {
  configure,
  addParameters,
  addDecorator
} from '@storybook/vue'
import {
  Vue
} from 'vue-property-decorator'
import {
  Centered
} from './components/centered'
import {
  Installer
} from '../src/Installer'
import {
  withKnobs
} from '@storybook/addon-knobs'
import '../src/assets/variables.css'
import '../src/assets/theme.css'
import '../src/assets/base.css'
import '../src/sass/main.scss'
import {
  withInfo
} from 'storybook-addon-vue-info'
// We import the favicon here
import './favicon.ico'

Vue.component('Centered', Centered)

const installer = new Installer(Vue)
installer.install(true)

addParameters({
  options: {
    sortStoriesByKind: true
  }
})

const stories = require.context('../src', true, /.stories.ts$/)

function loadStories() {
  stories.keys().forEach(filename => stories(filename))
}

addDecorator(withKnobs)
addDecorator(withInfo)

configure(loadStories, module)

And the preview-header.html (or manager-header.html):

<link rel="shortcut icon" href="./favicon.ico">

We've tried these routes too:

<link rel="icon" href="<%= BASE_URL %>favicon.ico">

And

<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">

Using the first option we see that the favicon is broken, however we don't see in the bundle the favicon.

System:

  • OS: MacOS
  • Device: Macbook Pro 2019
  • Browser: All
  • Framework: Vue
  • Version: 5.0.3
question / support ui

Most helpful comment

Here's my setup. First in package.json scripts:

"storybook": "start-storybook -p 9009 -s public"

Then in .storybook/manager-head.html (NOT manager-header.html):

<link rel="shortcut icon" href="/storybook.ico">
<link rel="icon" type="image/png" href="/storybook.png" sizes="192x192">

Then in public:

$ ls public/
storybook.ico   storybook.png

Hope that helps!

All 2 comments

Here's my setup. First in package.json scripts:

"storybook": "start-storybook -p 9009 -s public"

Then in .storybook/manager-head.html (NOT manager-header.html):

<link rel="shortcut icon" href="/storybook.ico">
<link rel="icon" type="image/png" href="/storybook.png" sizes="192x192">

Then in public:

$ ls public/
storybook.ico   storybook.png

Hope that helps!

My bad, I meant .storybook/manager-head.html. Works perfectly now, thanks! Maybe adding this to the docs would help other people too 🙂

Was this page helpful?
0 / 5 - 0 ratings