Skip to content

Instantly share code, notes, and snippets.

@doque
Created March 31, 2017 13:32
Show Gist options
  • Save doque/b12ac55a8d6771141ccbb5def4437bae to your computer and use it in GitHub Desktop.
Save doque/b12ac55a8d6771141ccbb5def4437bae to your computer and use it in GitHub Desktop.
require('babel-register');
const path = require('path');
const cssLoaders = require('../webpack.config.babel.js').cssLoaders;
// Overrides the Storybook Base Webpack Config
module.exports = function (storybookBaseConfig, configType) {
// configType has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.
console.log(`🤖 storybook is building for ${configType}`);
const isProd = configType === 'PRODUCTION';
// Enable usage of SASS Modules
storybookBaseConfig.module.loaders.push(
{
test: /.scss$/,
// Storybook needs to explicitly enable style-loader
loaders: [ 'style-loader' ].concat(cssLoaders),
include: path.resolve(__dirname, '../')
},
{
test: /\.(eot|svg|ttf|woff|woff2|html)$/,
exclude: /node_modules/,
loaders: [ 'file-loader' ],
},
{
test: /.json$/,
loaders: [ 'json-loader' ]
}
);
storybookBaseConfig.output.publicPath = 'http://localhost:6006/';
storybookBaseConfig.devtool = isProd ? 'source-map' : 'eval';
return storybookBaseConfig;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment