Storybookにもbabel-polyfillを追加する。
.storybook/webpack.config.jsを以下の内容で作成。
webpack.config.js
module.exports = function(storybookBaseConfig, configType) {
storybookBaseConfig.entry.preview.unshift('babel-polyfill')
}
Storybook 2.21.0で確認
おまけ
自分のプロジェクトでは、babel適用のコードは.es6
という拡張子で書いているので、以下のようになる
webpack.config.js
module.exports = function(storybookBaseConfig, configType) {
storybookBaseConfig.entry.preview.unshift('babel-polyfill')
storybookBaseConfig.resolve.extensions.unshift('.es6')
storybookBaseConfig.module.loaders.push({
test: /\.es6$/,
exclude: /node_modules/,
loader: 'babel',
})
return storybookBaseConfig;
}