Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config.module.rules[0].query.cacheDirectory = findCacheDir({
name: 'react-storybook',
});
// Check whether addons.js file exists inside the storybook.
// Load the default addons.js file if it's missing.
const storybookDefaultAddonsPath = path.resolve(__dirname, 'addons.js');
const storybookCustomAddonsPath = path.resolve(configDir, 'addons.js');
if (fs.existsSync(storybookCustomAddonsPath)) {
logger.info('=> Loading custom addons config.');
config.entry.manager.unshift(storybookCustomAddonsPath);
} else {
config.entry.manager.unshift(storybookDefaultAddonsPath);
}
const defaultConfig = createDefaultWebpackConfig(config);
// Check whether user has a custom webpack config file and
// return the (extended) base configuration if it's not available.
const customConfigPath = path.resolve(configDir, 'webpack.config.js');
if (!fs.existsSync(customConfigPath)) {
logger.info('=> Using default webpack setup based on "Create React App".');
return defaultConfig;
}
const customConfig = require(customConfigPath); // eslint-disable-line
if (typeof customConfig === 'function') {
logger.info('=> Loading custom webpack config (full-control mode).');
return customConfig(config, configType, defaultConfig);
}
config.module.rules[0].query.cacheDirectory = findCacheDir({
name: 'react-storybook',
});
// Check whether addons.js file exists inside the storybook.
// Load the default addons.js file if it's missing.
const storybookDefaultAddonsPath = path.resolve(__dirname, 'addons.js');
const storybookCustomAddonsPath = path.resolve(configDir, 'addons.js');
if (fs.existsSync(storybookCustomAddonsPath)) {
logger.info('=> Loading custom addons config.');
config.entry.manager.unshift(storybookCustomAddonsPath);
} else {
config.entry.manager.unshift(storybookDefaultAddonsPath);
}
const defaultConfig = createDefaultWebpackConfig(config);
// Check whether user has a custom webpack config file and
// return the (extended) base configuration if it's not available.
const customConfigPath = path.resolve(configDir, 'webpack.config.js');
if (!fs.existsSync(customConfigPath)) {
logger.info('=> Using default webpack setup based on "Create React App".');
return defaultConfig;
}
const customConfig = require(customConfigPath); // eslint-disable-line
if (typeof customConfig === 'function') {
logger.info('=> Loading custom webpack config (full-control mode).');
return customConfig(config, configType, defaultConfig);
}
module.exports = storybookBaseConfig =>
createDefaultWebpackConfig(storybookBaseConfig, includePaths);
module.exports = (baseConfig, configType) => when(
always(configType !== 'PRODUCTION' && hotReloadDisabled),
evolve({
entry: {
preview: filter(complement(includes('webpack-hot-middleware'))),
},
plugins: filter(plugin => plugin.constructor.name !== 'HotModuleReplacementPlugin'),
}),
createDefaultWebpackConfig(baseConfig),
);