Skip to content

Commit

Permalink
Add flag for building static storybook site (#58050)
Browse files Browse the repository at this point in the history
* Adding storybook static site generation and percy storybook script

* feat: 🎸 build each Storybook in own folder, add --site flag doc

* Add flags site tag for exiting process

Co-Authored-By: Vadim Dalecky <streamich@users.noreply.github.com>

* Back out of percy-storybook integration

Co-authored-by: Vadim Dalecky <streamich@users.noreply.github.com>
  • Loading branch information
poffdeluxe and streamich authored Feb 20, 2020
1 parent 4aedf2b commit 2623976
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 9 additions & 5 deletions packages/kbn-storybook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const { first } = require('rxjs/operators');
const storybook = require('@storybook/react/standalone');
const { run } = require('@kbn/dev-utils');
const { generateStorybookEntry } = require('./lib/storybook_entry');
const { REPO_ROOT, CURRENT_CONFIG } = require('./lib/constants');
const { REPO_ROOT, ASSET_DIR, CURRENT_CONFIG } = require('./lib/constants');
const { buildDll } = require('./lib/dll');

exports.runStorybookCli = config => {
Expand Down Expand Up @@ -62,21 +62,25 @@ exports.runStorybookCli = config => {
// route errors
subj.toPromise(),

new Promise(() => {
new Promise(async () => {
// storybook never completes, so neither will this promise
const configDir = join(__dirname, 'storybook_config');
log.debug('Config dir:', configDir);
storybook({
mode: 'dev',
await storybook({
mode: flags.site ? 'static' : 'dev',
port: 9001,
configDir,
outputDir: flags.site ? join(ASSET_DIR, name) : undefined,
});

// Line is only reached when building the static version
if (flags.site) process.exit();
}),
]);
},
{
flags: {
boolean: ['rebuildDll'],
boolean: ['rebuildDll', 'site'],
},
description: `
Run the storybook examples for ${name}
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-storybook/storybook_config/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
This file is looked for by Storybook and included in the HEAD element
if it exists. This is how we load the DLL content into the Storybook UI.
-->
<script src="/dll.js"></script>
<link href="/dll.css" rel="stylesheet" />
<script src="./dll.js"></script>
<link href="./dll.css" rel="stylesheet" />
4 changes: 3 additions & 1 deletion src/dev/storybook/run_storybook_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ run(

log.verbose('Loading Storybook:', absolute);
process.chdir(join(absolute, '..', '..'));

require(absolute);
},
{
Expand All @@ -69,9 +70,10 @@ run(
flags: {
default: {},
string: [],
boolean: ['clean'],
boolean: ['clean', 'site'],
help: `
--clean Clean Storybook build folder.
--site Build static version of Storybook.
`,
},
}
Expand Down

0 comments on commit 2623976

Please sign in to comment.