-
-
Notifications
You must be signed in to change notification settings - Fork 297
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
[WIP] feat: offline-only export #2802
base: main
Are you sure you want to change the base?
Conversation
Try this Pull Request!Open Julia and type: julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="pg/self-contained-export")
julia> using Pluto |
Interesting! Curious if the bundler issues can be fixed easily! Did you look into external tools that could do this? (i.e. make an offline-ready snapshot version of this html file.) I tried the "Save complete page" feature from Chrome but that did not work. :( And did you consider solutions that involve a custom CDN? Maybe you could self-host? You need to statically serve the The solution could also be a Julia script: |
me too! some issues seem like noone cares to fix
I've tried parcel with various configurations, monolith and inliner. They all get stuck somewhere in the dynamically loaded images, in loading the modules despite them being text/javascript or some combination
No this is not an option for our use case, unfortunately.
This might be good to do either way. I'll make a small package that does this, it can be a nice workaround for now. |
And, of course, there is the service worker approach |
One problem with the SW is that it only works the second time a page is loaded, but you can work around it by triggering a refresh on the first load. You should check that this will work on |
Yes, that was my thought too
Well, it doesn't 🤦🏾w3c/ServiceWorker#578 |
Got it! Some changes I had to make: url in CSSFor the "transformers": {
"*.svg": [
"...",
"@parcel/transformer-inline"
]
},
"optimizers": {
"*.svg": [
"...",
"@parcel/optimizer-data-url"
]
} And also, I had to learn to remove the url in JSFor cases where we were using To solve this, I make add these URLs as fontsThis I still need to figure out! |
Also got mathjax and the fonts :) |
With the JS changes and inlining ionicon svgs, the exports work offline, with mathjax, only the fonts don't load. But inlining the svgs bring the bundled editor.css from 80kB to 120kB and that's acceptable! So we can do this in the main bundle, and we don't need a separate bundle for offline support. I'm thinking of tweaking our font stacks a bit to make the fallback fonts look more like Alegreya and Vollkorn, and just keeping it like that! Then the offline html will be just 1.5MB with slightly different looking fonts when viewing without internet. But we don't need a second bundle :) |
#2896 to make the fallback fonts look nicer :) which is something i wanted to do for a long time! |
Is there any chance this can be merged as-is? This seems like it is useful for procedurally generating notebook pages to HTML even without a UI:
|
Hey @sjkelly ! I also like this PR! Btw the code you wrote already works on the current Pluto release :) but the generated HTML does not work offline. I want to enable this feature by default for all exports, so that our HTML files will always work without relying on the jsdelivr.com CDN like we currently do. What's left for this PR is #2898. Without that, the generated HTML files will not use Pluto's standard typefaces but always use one of the default system fonts. And that's not nice, because we want a what-you-see-is-what-you-get experience. |
will fix: #2771 (eventually)
[WIP]: this is an attempt to bundle all the assets required for a static export to work completely offline, with all the assets bundled in the HTML.
Parcel is supposed to do this, but there are quite a few caveats that make this not work as-is.
Current state:
creates a 17MB HTML file with all the assets bundled, but
Needs more work