Skip to content

Instantly share code, notes, and snippets.

@hco
Created June 12, 2018 10:32
Show Gist options
  • Save hco/75e3daf899ed988dfb2ca6c83df4ba82 to your computer and use it in GitHub Desktop.
Save hco/75e3daf899ed988dfb2ca6c83df4ba82 to your computer and use it in GitHub Desktop.
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import { configure } from '@storybook/react';
// automatically import all files ending in *.stories.js
const req = require.context('../src', true, /.stories.(jsx?|tsx)$/);
function loadStories() {
req.keys().forEach((filename) => req(filename));
}
configure(loadStories, module);
// load the default config generator.
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js');
module.exports = (baseConfig, env) => {
const config = genDefaultConfig(baseConfig, env);
// Extend it as you need.
// For example, add typescript loader:
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('awesome-typescript-loader')
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment