1.1.2 • Published 10 years ago

react-stubs v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

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.

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago