Workspace
GitbookGraphql2021-01-15
π workspace for gatsby theme development
-
gatsby-node.js:- make sure the data directory exists:
onPreBootstrap - define the event type:
sourceNodes,createTypes - define resolvers for any custom fields (slug)
- query for events and create pages
- make sure the data directory exists:
gatsby-config.jsevents.js: useStaticQuery- Inside
gatsby-node, only fetchid,slug; insrc/templates/events.js, useStaticQuery to fechallEventagain for details - in
event.js, usegraphqlinstead ofStaticQueryfor individually query. -
package -> root
$ yarn workspace site add gatsby react react-dom theme@* $ yarn workspaces info $ yarn workspace theme add -P react react-dom gatsby $ yarn workspace theme add -D react react-dom gatsby $ yarn workspace site develop $ yarn workspace theme add gatsby-source-filesystem gatsby-transformer-yaml $ yarn workspace theme add gatsby-plugin-theme-ui theme-ui $ yarn workspace theme develop $ npm login $ cd theme/ $ npm publish --access public
π yarn commands
-
add-W,--ignore-workspace-root-check, required to run yarn add inside a workspace root-P,--peer, save package to yourpeerDependencies
- workspace: components add -D react
- workspaces: list, foreach, focus
- upgrade: yarn up lodash
- config
- info
- link
- publish
π worktree
-
package.json:
{ "private": true, "workspaces": ["packages/*"] } Yarn WorkspacesvsLerna: Lerna will use Yarnβs workspaces if possible. Lerna is a high-level layer of the low-level Yarn implementation.
