First, you need to initialize the API for your style guide config.
Using a JavaScript object:
import styleguidist from 'react-styleguidist'
const styleguide = styleguidist({
logger: {
warn: console.warn,
info: console.log,
debug: console.log
},
components: './lib/components/**/*.js',
webpackConfig: {
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true
}
}
]
}
]
}
}
})
infoAny output is disabled by default, you may need to define your own logger.
Using a config file:
import styleguidist from 'react-styleguidist'
const styleguide = styleguidist(require('../styleguide.config.js'))
Or auto searching a config file:
import styleguidist from 'react-styleguidist'
const styleguide = styleguidist()
See all available config options.
Methods#build(callback)
# Arguments#
callback(err, config, stats)
(Function): A callback to be invoked when style guide is built:
err
(Object): error details.config
(Object): normalized style guide config.stats
(Object): webpack build stats.(Compiler): webpack Compiler
instance.
import styleguidist from 'react-styleguidist'
styleguidist(require('../styleguide.config.js')).build(
(err, config) => {
if (err) {
console.log(err)
} else {
console.log('Style guide published to', config.styleguideDir)
}
}
)
server(callback)
# Arguments#
callback(err, config)
(Function): A callback to be invoked when style guide is built:
err
(Object): error details.config
(Object): normalized style guide config.(Object): Object containing a webpack Compiler
instance and the React Styleguidist server
import styleguidist from 'react-styleguidist'
styleguidist(require('../styleguide.config.js')).server(
(err, config) => {
if (err) {
console.log(err)
} else {
const url = `http://${config.serverHost}:${config.serverPort}`
console.log(`Listening at ${url}`)
}
}
)
makeWebpackConfig([env])
# Arguments#
env
='production'
] (String): production
or development
.(Object): webpack config.
Example#module.exports = [
{
},
require('react-styleguidist').makeWebpackConfig()
]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4