Skip to content

Commit

Permalink
fix(www): update storybook docs to prefer Gatsby ES6 module in webpac…
Browse files Browse the repository at this point in the history
…k config (#10669)

The steps in the current documentation for using Storybook with Gatsby (https://www.gatsbyjs.org/docs/visual-testing-with-storybook/) don't work because importing Link from gatsby in any component breaks. 

This is because several internals get required as a result of requiring anything from the default commonjs build (which would have been tree shaken before #9123) and eventually require a non-existent `pages.json`. 

More details are at #10668

This pull request updates the documentation with a quick fix (setting resolve.mainFields in the storybook webpack config override thereby _preferring_ es6 gatsby over commonjs) 

Fixes #10662
  • Loading branch information
sidharthachatterjee authored and DSchau committed Dec 27, 2018
1 parent db45762 commit 4a6ef93
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/docs/visual-testing-with-storybook.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ module.exports = (baseConfig, env, defaultConfig) => {
require.resolve("@babel/plugin-proposal-class-properties"),
]

// Prefer Gatsby ES6 entrypoint (module) over commonjs (main) entrypoint
defaultConfig.resolve.mainFields = ["browser", "module", "main"]

return defaultConfig
}
```
Expand Down

0 comments on commit 4a6ef93

Please sign in to comment.