Skip to content

Commit

Permalink
add dev config
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jan 13, 2019
1 parent 481c4ee commit ac537b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,10 @@ gulp.task(
);

gulp.task('storybook', () => {
// get project name
const dir = resolveCwd('./');
InitStoryConfigJs(dir);
const config = require(path.join(dir, './package.json'));
InitStoryConfigJs(dir, true, config);
storybook({
mode: 'dev',
port: '9001',
Expand All @@ -968,10 +970,11 @@ gulp.task('storybook', () => {
gulp.task('storybook-build', () => {
const dir = resolveCwd('./');
// remove ./build
const config = require(path.join(dir, './package.json'));
const buildFolder = resolveCwd('./build');
shelljs.rm('-rf', buildFolder);

InitStoryConfigJs(dir);
InitStoryConfigJs(dir, false, config);

storybook({
mode: 'static',
Expand Down
8 changes: 5 additions & 3 deletions lib/initStoryConfigJs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs-extra');
const path = require('path');

module.exports = dir => {
module.exports = (dir, dev, { name, homepage }) => {
const configJs = `
import { configure, addDecorator } from '@storybook/react';
import { withNotes } from '@storybook/addon-notes';
Expand All @@ -12,12 +12,14 @@ module.exports = dir => {
require('${dir}storybook/index.js');
}
addDecorator(withNotes);
${dev && 'addDecorator(withNotes)'};
addDecorator(withSource);
addDecorator(
withOptions({
name: 'RC-TOOLS'
name: '${name}'
url: '${homepage}',
title:'${name}'
})
);
Expand Down

0 comments on commit ac537b7

Please sign in to comment.