UNPKG

1.98 kBJavaScriptView Raw
1import { load } from '../'
2import path from 'path'
3import fs from 'fs'
4
5// Generate fresh babelrc on each run
6require('../_utils/babelrc')(path.resolve(__dirname, '.storybook'))
7
8// Add valid CWD_SRC fro require.context (needs to be literal)
9const configPath = path.resolve(__dirname, './.storybook/config.js')
10fs.readFile(configPath, 'utf8', function(err, data) {
11 if (err) {
12 return console.log(err)
13 }
14 const result = data.replace(/require\.context\('(.*?)'/g, function(
15 match,
16 param
17 ) {
18 return match.replace(
19 param,
20 path.resolve(process.cwd(), 'src').replace(/\\/g, '/')
21 )
22 })
23
24 fs.writeFile(configPath, result, 'utf8', function(err) {
25 if (err) return console.log(err)
26 })
27})
28
29module.exports = module.exports.default = load('storybook', {
30 start: {
31 port: 9000,
32 host: 'localhost',
33 'static-dir': null,
34 'config-dir': path.resolve(__dirname, '.storybook')
35 }
36})
37
38/*
39Usage: start-storybook [options]
40
41Options:
42
43-h, --help output usage information
44-V, --version output the version number
45-p, --port [number] Port to run Storybook (Required)
46-h, --host [string] Host to run Storybook
47-s, --static-dir <dir-names> Directory where to load static files from, comma-separated list
48-c, --config-dir [dir-name] Directory where to load Storybook configurations from
49--quiet Suppress verbose build output
50For build-storybook
51Usage: build-storybook [options]
52
53Options:
54
55 -h, --help output usage information
56-V, --version output the version number
57-s, --static-dir <dir-names> Directory where to load static files from, comma-separated list
58-o, --output-dir [dir-name] Directory where to store built files
59-c, --config-dir [dir-name] Directory where to load Storybook configurations from
60-w, --watch Enable watch mode*/