It will force your *.stub.jsx?
files to overlap the non stub files in a given Webpack config file.
const webpack = require('webpack');
module.exports = function(storybookBaseConfig, configType) {
const jsExtensions = /(\.jsx?)$/;
storybookBaseConfig.plugins.unshift(
new webpack.NormalModuleReplacementPlugin(jsExtensions, function(hit) {
if (!hit.userRequest) {
return;
}
const stub = hit.userRequest.replace(jsExtensions, '.stub$1');
try {
require.resolve(stub);
hit.request = hit.request.replace(hit.userRequest, stub);
hit.resource = hit.resource.replace(hit.userRequest, stub);
hit.userRequest = stub;
} catch(error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
}
})
);
The simplest most straightforward composer ever.
import composeStub from 'react-stubs';
import { Address } from './factories';
export default composeStub(({ person }) => ({
person,
address: Address.build(),
}));
If you like this project just give it a star :) I like stars.