How to use a local Gatsby plugin or theme?
See original GitHub issueHi,
I have not found a way to create a Gatsby plugin or theme in the libs folder and make it discoverable in the Gatsby-config.js of any given app.
Is that possible?
for example, my workspace is called websites
.
I manually add a theme gatsby-theme-base
in the libs folder and populate all the relevant files (workspace.json, nx.json, tsconfig…).
When I try to import this theme into a Gatsby app, it fails to see it.
Any idea how to create plugins or themes in libs folder that can be used in the apps?
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Creating a Local Plugin - Gatsby
This is a similar process to setting up yarn workspaces for development with Gatsby themes (which is the recommended approach for developing themes)....
Read more >Using Plugins in Gatsby - DigitalOcean
The easiest way is to create a new directory in the root of your site named plugins , and then place the local...
Read more >How to Set Up a GatsbyJS Theme - X-Team
Using Your Theme on an Existing Gatsby Site · Create a folder and place your Gatsby site inside. · Create a Yarn Workspace...
Read more >Gatsby Plugin – Theme UI
The name of the preset you'd like to use to style code blocks inside your markdown files. The available presets can be found...
Read more >Building Gatsby Themes For WordPress-Powered Websites
Gatsby provides an official gatsby-source-wordpress plugin. To make it work, we need to prepare our WordPress end. More precisely, we need to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @xiongemi. Thanks for your support but why was this issue closed? clearly that your solution is not a production-ready solution. You should consider providing some custom builder and generators in order to support gatsby libraries as part of nx workspace correctly. it should support
--with-deps
when building the app that uses the gatsby libs, it should be able to support tsconfig paths so it will be possible to use the import path of the library insidegatsby-config.js
fileFor gatsby plugin:
To make a gatsby plugin under lib to be discovered by gatsby app:
in your gatsby.config.js, in plugins, add
require.resolve(<path to your libfolder>)
, it should be discovered by gatsby:For Gatsby Theme:
require.resolve(<path to your libfolder>)
I have played around with it in my repo: https://github.com/xiongemi/nx-gatsby-blogs/tree/gatsby-theme, the theme app is https://github.com/xiongemi/nx-gatsby-blogs/tree/gatsby-theme/apps/blog-medium and the app consumes this theme is https://github.com/xiongemi/nx-gatsby-blogs/tree/gatsby-theme/apps/blog-medium-emily-xiong