diff --git a/lib/gulpfile.js b/lib/gulpfile.js index aa15ee7..6d9dbca 100644 --- a/lib/gulpfile.js +++ b/lib/gulpfile.js @@ -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', @@ -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', diff --git a/lib/initStoryConfigJs.js b/lib/initStoryConfigJs.js index 2d6e780..fb5cab5 100644 --- a/lib/initStoryConfigJs.js +++ b/lib/initStoryConfigJs.js @@ -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'; @@ -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}' }) );