If you have a number of samples/demos in a Collection that you’d like to keep logically separated in different Glitch projects, is there a way to import or access code from another project within the Collection? Is there any common file system they can access? There’s common boiler plate in each sample that I’d like to manage from a single place.
I suspect this isn’t possible, but wanted to ask the community first.
What you can do is push some of your code to GitHub and in your package.json (if you’re importing Node.js modules), specify the URI of the repository like so:
For more information, check out this section of the official documentation.
You could also reference the tarball of a project (after bundling the project folder) as a dependency if it’s accessible via a URL from your project:
You might be able to pull off the second method quite easily if you force Glitch to serve the files of your project via its built-in file browser. I believe the root directory of your project must not contain a README.md or index.html to enable such behavior.
I think the git route is probably the way to go but I’ve got a roundabout idea that may also work and keep you entirely inside the glitch ecosystem.
You set up a glitch project that acts as an API for your boilerplate files, so this project will serve the boilerplate at a specific endpoint. Then in your subsequent projects you utilize the
install config command to send a request to that API and update/replace the boilerplate files just before the container starts properly. Then ideally your boilerplate is maintained in the API project yet updated on the fly in your others.
Thanks for the replies! To clarify, where is the install config specified/invoked? In package.json?