I have a Gatsby generated website which I deploy using Netlify.
I've followed the tutorial listed here to create a custom/local source plugin in a very similar fashion.
The custom plugin obviously has its own package.json
file and therefore requires npm i
for things to work when imported via the root level gatsby-config.js
.
What's the easiest way of getting the dependencies to install for my custom plugin on my Netlify deploy?
Simpliest, I think you can instruct yarn (or npm) to cd into your plugin folder then run install.
In netlify, you can change the default build script from the default gatsby build
to yarn build
(or the npm equivalent).
Then, in your root package.json, in scripts
, add this:
"install-plugin": "cd ./plugins/your-plugin-name && yarn",
"build": "yarn install-plugin && gatsby build"
It's not the most elegant solution when you have more than a few custom plugins; for that case I think a custom post install script could work.
Alternatively you could also add all dependencies of the plugin directly to the root package.json!