Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI/Storyshots: Specify custom sb extract Chromium exe #15878

Merged
merged 2 commits into from Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/storyshots/storyshots-puppeteer/README.md
Expand Up @@ -123,6 +123,8 @@ initStoryshots({
});
```

Alternatively, you may set the `SB_CHROMIUM_PATH` environment variable. If both are set, then `chromeExecutablePath` will take precedence.

### Specifying a custom Puppeteer `browser` instance

You might use the async `getCustomBrowser` function to obtain a custom instance of a Puppeteer `browser` object. This will prevent `storyshots-puppeteer` from creating its own `browser`. It will create and close pages within the `browser`, and it is your responsibility to manage the lifecycle of the `browser` itself.
Expand Down
2 changes: 1 addition & 1 deletion addons/storyshots/storyshots-puppeteer/src/config.ts
Expand Up @@ -52,7 +52,7 @@ const asyncNoop: () => Promise<undefined> = async () => undefined;

export const defaultCommonConfig: CommonConfig = {
storybookUrl: 'http://localhost:6006',
chromeExecutablePath: undefined,
chromeExecutablePath: process.env.SB_CHROMIUM_PATH,
getGotoOptions: noop,
customizePage: asyncNoop,
getCustomBrowser: undefined,
Expand Down
8 changes: 7 additions & 1 deletion docs/workflows/storybook-composition.md
Expand Up @@ -23,7 +23,7 @@ In your [`storybook/main.js`](../configure/overview.md#configure-story-rendering
<!-- prettier-ignore-end -->

<div class="aside">
We would like to point out that there's some limitations to composition. For now addons in composed Storybooks will not work as they do in non composed Storybooks.
We would like to point out that there's some limitations to composition. For now addons in composed Storybooks will not work as they do in non composed Storybooks.
</div>

## Compose local Storybooks
Expand Down Expand Up @@ -70,6 +70,12 @@ So far we've covered how we can use composition with local or published Storyboo
npx sb extract
```

<div class="aside">

`sb extract` uses [Puppeteer](https://www.npmjs.com/package/puppeteer), which downloads and installs Chromium. Specify your own locally-installed Chromium executable by setting the environment variable `SB_CHROMIUM_PATH`.

</div>

Using this command will generate a `stories.json` file in the default build directory (`storybook-static`) with information regarding your Storybook. Here's how it might look:

<!-- prettier-ignore-start -->
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/extract.ts
Expand Up @@ -52,7 +52,7 @@ const useLocation: (input: string) => Promise<[string, () => void]> = async (inp
const usePuppeteerBrowser: () => Promise<puppeteerCore.Browser> = async () => {
const args = ['--no-sandbox ', '--disable-setuid-sandbox'];
try {
return await puppeteerCore.launch({ args });
return await puppeteerCore.launch({ args, executablePath: process.env.SB_CHROMIUM_PATH });
} catch (e) {
// it's not installed
logger.info('installing puppeteer...');
Expand Down