Updated: Having trouble with code components - they don’t appear when I publish to vercel or view my local dev server on localhost.
I’m using the plasmic loader method
Original text:
~I’m getting my head around creating code components.~
~Can I use the same GitHub repo to register the code components, and also to publish to from plasmic studio?~
~I’m using the plasmic loader, not codegen~
I am not an expert at this, but I’ll share what I know so far:
I believe the Plasmic team mentioned that when using loader you wouldn’t see further commits in Github … or anywhere else for that matter (localhost) in terms of code changes. You’d have to use codegen for it to work like that.
If left as such, Vercel would auto trigger a redeploy when there are new commits on the main branch. Since Plasmic doesn’t trigger commits, nothing would happen. However, if you make changes to your code components on localhost and push to Github, Vercel will see and deploy.
To make Vercel aware of new publishes from Plasmic, you have to create a new webhook in Vercel, from Your project > Settings > Git > Deploy Hooks.
Once created, copy the webhook url and in Plasmic, where you configured the publish to Github, add a Call webhooks and and setup a new webhook using a POST to the webhook url you copied from Vercel.
So whenever you publish, it will call the Vercel webhook to trigger a redeploy (and load the latest changes in Plasmic).
Thanks @exhaustive_panther
That helps. I’ve set that up, and deployments are now happening when I publish from Plasmic, which is great.
However, I now realise that the main issue I was seeing before isn’t that publishing wasn’t working, but rather that my code components are not showing up in the published version of my app. They only appear in plasmic studio.
The images below illustrate this.
I can see my code components in Plasmic studio and have added them to the home page (image 1 - the blue “HelloWorld Someone” text & the list of names below are both code components).
Those code components also show up when previewing in plasmic studio (image 2)
However, they do not show up when I’m running my dev server and access localhost:3000 (image 3), nor do they show up when I trigger a deploy to vercel (image 4). In both of these, changes made to non-code changes ARE publishing successfully but the code components are missing entirely
My app host is currently localhost:3000 if that makes a difference?
Yes, it makes a difference. Your app host should be updated with your Vercel url so that Plasmic can load the custom components from there (instead of locally from your machine) - there are details here regarding this process: https://docs.plasmic.app/learn/multiple-environments/#managing-your-code-components-and-app-hosts
Thankyou for your excellent help again @exhaustive_panther - it’s made a huge difference to me being able to get up to speed on plasmic, much apprecitaed!
No problem, been there myself
The final issue, for anyone reading this later, is that I had registered my code components in plasmic-host.tsx rather than plasmic-init.ts
Once I moved the registration to plasmic-init everything started working as expected!