-
Notifications
You must be signed in to change notification settings - Fork 27
overhaul build system #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
overhaul build system #77
Conversation
makermelissa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this isn't passing the checks because it can't find the files. If you can get this working and the site functions without errors, I'm good with these changes.
|
This is a super annoying bug in snowpack: I thought I fixed it, as it worked locally, but it seems the timing is just different enough in GitHub Actions to be broken again. I actually believe is is generally broken on the main branch as well, as there is no guarantee that the build+deploy is actually from the expected version of files, but it might as well just use the old version still in the repo. Not deterministic in my understanding. I spent hours trying to fix this today - but at this point I'm wondering if a different tool chain would be more appropriate?
|
|
@tannewt, since you originally chose snowpack, what are your thoughts? |
2d9c598 to
24bafaf
Compare
|
@makermelissa @tannewt I updated the PR and migrated from snowpack to vite. Please read through the main PR description for all new changes in this PR. |
24bafaf to
9ad3924
Compare
|
I did a little more looking into this yesterday and I think this was a good choice of build system to go with. I would just like to get Scott's thoughts first, and I'm not sure his ETA for being back. Also, I'm going to be out most of this next week, so it may not be a good idea to merge right before that in the case of something unexpectedly breaking that needs fixing right away. So because this is a major change and the above reasons, I may hold out on merging until next week. |
|
I don't have any affinity for snowpack or experience with JS. So I'd leave it up to you both. |
|
Ok cool. Works for me. There's a few merge conflicts that need to be fixed first, then I'd like to test this locally, and then I think this will be good to go. |
9ad3924 to
0df1fce
Compare
|
rebased & fixed conflicts. Please test extensively, I only know and did the basics using USB, but I did not test the other workflows at all or in depth. |
0df1fce to
a4b7e02
Compare
|
updated and rebased to recent main branch. |
|
I don't think this works with the current web-workflow. CP devices directly load device.js via the embedded code.html page. There must be a way to expose this script using vite (of which I know almost nothing). Adding this stanza (found on the 'net) seems to work ok. That said, I did successfully build and deploy your changes and web-workflow works if invoked directly but not via the CP device landing page (404 error on device.js) |
|
Good catch @thess. That one isn't very obvious. |
a4b7e02 to
188fa81
Compare
|
@thess would this generated folder structure work for the web workflow? |
|
I believe so. The device.js file must be accessible at https://code.circuitpython.org/assets/js/device.js. The purpose of this script is to bootstrap load the website via javascript as if it is loading it right on the device. You can test by loading the site locally as secure and going to https://localhost:8080/code/#host=circuitpython.local with a device plugged in. Change circuitpython.local as needed for the device host name. |
|
Actually, it looks like I only have the code/index.html on my computer locally. Here's the contents: |
|
Thanks - then this should work just fine. I already updated the PR to generate exactly the folder structure as shown above. I simple moved the |
|
@Kriechi - Looks good, thanks for this |
|
One more item -- favicon.ico needs to be exposed in |
188fa81 to
8db82a9
Compare
|
Done! |
|
Sorry for being such a nag -- I'm not very well versed in this environment. I noticed the logo is not rendering in the vite production build when served by a regular web server like nginx. The embedded base64 PNG is causing 404 errors. Moving the logo??.png files to the public folder and fixing up index.html to find them seems to solve this issue. I hope this is the last tweak on this PR. |
8db82a9 to
a380211
Compare
|
Fixed! New cleaned up folder structure: |
a380211 to
d9b7dde
Compare
|
This looks really good. The only change that I would like to see is an option to be able to run this as https by passing a command. This was something I used frequently prior to this PR and this PR appears to remove that functionality. As it is, chrome doesn't accept the SSL cert just by passing |
|
Curious what use cases you have for HTTPS specifically? Without having used or reviewed them myself, these seem to be popular plugins for vite: If one of these fits your needs and previous workflow, I can link them in the README (again). |
|
Mostly because the final site is https://code.circuitpython.org and it's useful to test because sometimes CORS issues come up where they may not on http or vice versa. It's also sometimes useful to test it as http, which is why I'd like the option. The mkcert option sounds good. Thanks. |
|
@makermelissa you can probably keep that in a local (not committed to the repo) config file, and pass it to vite using a command like Or do you want to make it part of the default config? Not sure how many actually need it. |
This sounds like a good solution. |
makermelissa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the merge conflicts and then I'm happy to merge this.
This also avoids having a local diff when developing.
d9b7dde to
7dc0212
Compare
|
rebased & no more conflicts! |
|
Thank you for your hard work on this. |
The current build system is using snowpack, which is deprecated and has not received updates in the last two years.
Currently, the repository contains a compiled/generated copy of all resources which is outdated and can cause version mismatches due to race conditions during compilation with snowpack (see FredKSchott/snowpack#3289). This introduces a non-deterministic deployment to be pushed out, potentially containing old (insecure) code. Furthermore, developing locally causes a constant diff against these files.
This PR removes the stale copy of compiled resources from the repository.
This PR migrates from the deprecated snowpack to the actively maintained vite build system, as recommended by snowpack themselves as possible upgrade path (see https://github.com/FredKSchott/snowpack/blob/main/README.md).
This PR restructures the assets folders to be top-level for each resource type, which fits better with vite.
This PR brings in all 3rd party dependencies and libraries to be part of the compiled single page app. No more online downloads from CDNs.
This PR also updates the necessary GitHub Actions workflow files - these need additional testing which I cannot run as part of this PR alone.