Hey there fellow Experts.
This is a problem I’ve faced frequently and was wondering how others manage it. I’ve often had issues with changes I make to the JS Code in the Builder settings get saved and then disappear the next day when I open the app. This happens especially when I have other collaborators on the app who also work on the backend.
Although I understand why exactly this is happening, I was wondering if anyone has tips as to how they maintain this? I do copy the code to a local file and push to a git repo but does any one have a better solution?
Hi Arjun - as you are probably aware, the builder is not multi user so this would be a reason for JS disappearing.
Hey Carl. Yes I’m aware that that’s why it’s happening. I remember reading it on Knack docs as well.
I understand that in that particular scenario, it is unavoidable. I’m still curious on finding if someone else has a better method of maintaining versions of their code once they’re done with an update…
You may find that my good friend @Johnny_Parsons_86 may be able to help as he is a coder and I’m not
Hi @Arjun and @CarlHolmes,
I have come across this previously but think you just have to be careful and make back ups on a local machine and Git repo’s.
I have two Idea’s you could explore
This is the most elaborate but it might be worth exploring and creating a Chrome extension that can copy your code to a Git Repo. Have not explored this myself but Chrome extensions are very cool and easy to set up with a manifest.json file.
Hope this help
@Johnny_Parsons_86 both great ideas. May be I should look into developing the Chrome extension.
hi! in case it helps:
we never allow simultaneous building on the same app. a frustrating constraint, i know
for code changes, we track custom JS/CSS in a github repo. We test code changes in a copy of the app, then branch/review/merge the code in the repo before copy/pasting it to the production app.
i agree with @Johnny_Parsons_86 that lazy-loading code from external files is an interesting idea. In which case you could manage your version code completely in a Git repo with your own deployment process.
Hope that helps.
Hi Arjun. Here’s how I do it.
I created a framework using webpack and it combines all of the files and directories into 1 main.js file. These files are pushed to gitlab. Then it saves the project to an s3 bucket and provides me with a CDN. I have a different cdn URL for each branch of the repo. The CDN is injected into the project in the JS section of the Knack app. My team and I just have to push via git cli and it updates the Knack project automatically.
Thanks for the responses guys. I’ve been trying to use a node app I have to get a js file I’m working on to Lazyload into the app. I’m able to get commands to run in general but I’m not able to use any of the Knack handlers (“knack-scene-render.any”, etc.,) to work in my app.
Any idea on how I can get this running?