pocotan001 / react-styleguide-generator

Easily generate a good-looking styleguide by adding some documentation to your React project.
http://pocotan001.github.io/react-styleguide-generator
MIT License
700 stars 76 forks source link

How to remove `styleguide` static field on production environment? #1

Closed Cap32 closed 9 years ago

Cap32 commented 9 years ago

The styleguide field may contain some big data, but that is useless on production environment.

pocotan001 commented 9 years ago

If a production code is used, it is recommended that you do not include the styleguide field. for example, as follows:

components/button
├─ index.js
└─ styleguide.js

index.js

import React from 'react';

export default class Button extends React.Component {
  render () {
    return (
      <button className='button'>
        {this.props.children}
      </button>
    );
  }
}

styleguide.js

import React from 'react'
import Button from './'

export default class extends React.Component {
  static styleguide = {
    category: 'Examples',
    title: 'Button'
  }

  render () {
    return (
      <Button>Button</Button>
    )
  }
}

It will include only styleguide.js.

rsg 'components/**/styleguide.js'
Cap32 commented 9 years ago

Thank you! 😄