Hey all,
I’m new to Sage, relatively new to composer and npm. And I’m working on a Sage 9 project. This far I’m loving it I’ve successfully created my custom theme and even a Sage 9 child theme.
Now, I come to a point where I would like to make use of reusable code from my private github repos. For example I would like to:
- Reuse php Classes for the admin backend in multiple projects. For example a class to check if my theme has a newer version available on my github and update.
- Reuse Gutenberg blocks in multiple porjects.
What I’ve got so-far (not working properly)
Alright, for public repo’s I would add to my package.json
"dependencies": {
"theme-updater": "myGithubUsername/theme-updater#branch",
}
Then in app/setup.php I could load it like:
include_once dirname(__FILE__) . "/../node_modules/theme-updater/ThemeUpdater.php";
new ThemeUpdater();
Alright, this might work in development. But it won’t work in production like this. Because, when I push the code, after building. to github it’s, obvious, without the node_modules
. And my wordpress website doesn’t build the project. It simply downloads the theme zip and installs it regularly (I presume, I havn’t finished the update class yet )
So two main questions:
- How would I include my github snippits to my sage project in a way they are included in the local build.
- How would I handle private github repos to grab the code from
Thoughts
- Would this work in Sage 9 and Sage 10?