react-stubs

1.1.2 • Public • Published

React-stubs Build Status

Setup

Configure webpack

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;
        }
      }
    })
  );

API

composeStub (react-komposer helper)

The simplest most straightforward composer ever.

Usage

import composeStub from 'react-stubs';
import { Address } from './factories';
 
export default composeStub(({ person }) => ({
  person,
  address: Address.build(),
}));

Motivate

If you like this project just give it a star :) I like stars.

Package Sidebar

Install

npm i react-stubs

Weekly Downloads

14

Version

1.1.2

License

MIT

Last publish

Collaborators

  • zvictor