Hi Koos
I know your struggle and have a solution fr you. GitHub Pages does not support custom builds with NPM etc. But you can use GitHub Actions with a config of like 100 lines or Netlify with a config of a few lines.
Some Ruby or Jekyll projects use rake
to manage npm install and other tasks but I struggle to get into it.
My approach is to use a Makefile
and call it with make
command. That comes from the C compilation background but you’ll also see it in Python and C++ projects. It comes with mac and linux and I think you can install on windows
Here is my simple Jekyll related makefile.
To use it:
cd repo
make install
make build
And now the site is built.
Run those commands on GitHub Actions or your remote server and it will work the same. On Netlify you don’t even need to run make install as Netlify finds a Gemfile and package.json and installs for you.
I use a Makefile for all my Jekyll projects as it let’s me manage by commands easily and I can run multiple tasks underneath like NPM and Bundle steps to install or build.
For example to you can define commands as
install-js:
npm install
install-gems:
bundle config set --local path vendor/bundle
bundle install
install: install-js install-gems
Which means when you run
make install
It runs
npm install
bundle config...
bundle install
And you can define build as
build:
npm run build
bundle exec jekyll build --trace
So you just have to run make build
and it will run both commands.
And then you would have make build
as the build step in your Netlify config or GH Actions workflow.
Note that make will exit on failure so it effectively does
npm run build && bundle exec ...