Skip to content

Commit

Permalink
Updated instructions to prioritise npx method (#21169)
Browse files Browse the repository at this point in the history
* Updated instructions to prioritise npx method

As this is the method recommended by Storybook I think we should prioritise it in the setup instructions over installing the CLI globally.

* Switch > with <

* Add note regarding use of npx over npm

Thanks @laurieontech for the wording

Co-authored-by: GatsbyJS Bot <[email protected]>
  • Loading branch information
Chrish Dunne and GatsbyJS Bot authored Feb 13, 2020
1 parent c156da7 commit de58ef1
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions docs/docs/visual-testing-with-storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,15 @@ As your project grows over time having this information available will be invalu

## Setting up your environment

To set up Storybook you need to install dependencies and do some custom configuration. First, install the Storybook CLI.
> Note that the following instructions are using [npx](https://www.npmjs.com/package/npx). `npx` is a part of npm and in this case it allows you to automatically generate a file/folder structure complete with the default configuration. If you're running an older version of `npm` (`<5.2.0`) you should run the following command instead: `npm install -g @storybook/cli`. You can then run `sb init` from your Gatsby root directory to initialise Storybook.
```shell
npm install -g @storybook/cli
```

Once the CLI is installed, the next step is to run the `sb init` command that is now available from the root directory of your Gatsby project.
To set up Storybook you need to install dependencies and do some custom configuration. You can get started quickly by using the automated command line tool from your Gatsby root directory:

```shell
cd my-awesome-gatsby-project
sb init
npx -p @storybook/cli sb init
```

> Note that if you're running a recent version of `npm` (5.2.0+) you can run the following single command instead: `npx -p @storybook/cli sb init`, which is the recommended method by Storybook. This doesn't install the CLI on your machine, thereby ensuring you're always running the latest version of the CLI.
The `sb init` command bootstraps the basic config necessary to run Storybook for a React project. However, since this is for a Gatsby project, you need to update the default Storybook configuration a bit so you don't get errors when trying to use Gatsby specific components inside of the stories.
This command adds a set of boilerplate files for Storybook in your project. However, since this is for a Gatsby project, you need to update the default Storybook configuration a bit so you don't get errors when trying to use Gatsby specific components inside of the stories.

To update your Storybook config open `.storybook/config.js` and modify the content as follows:

Expand Down

0 comments on commit de58ef1

Please sign in to comment.