Closed rjsandman closed 3 years ago
Yup, those are both viable solutions. I have a new project in the open now that does this for you automatically (still WIP) so I'm not sure if it's worth bringing over the changes to this demo repo.
You can clone freshie/examples/svelte
but replace @freshie/ssr.node
with @freshie/ssr.worker
here.
Replace all
workspace:
versions with real versions, though
You can freshie build
, and then upload the build/client
to a GCP bucket (or wherever) and then upload build/server
as a CF Worker.
Thanks! This is great! After npm install and building I'm getting this error:
[freshie] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
---- On Tue, 17 Nov 2020 14:49:55 -0500 Luke Edwards notifications@github.com wrote ----
Yup, those are both viable solutions. I have a new project in the open now that does this for you automatically (still WIP) so I'm not sure if it's worth bringing over the changes to this demo repo. You can clone https://github.com/lukeed/freshie/tree/master/examples/svelte but replace @freshie/ssr.node with @freshie/ssr.worker https://github.com/lukeed/freshie/blob/master/examples/svelte/package.json#L8.
Replace all workspace: versions with real versions, though
You can freshie build, and then upload the build/client to a GCP bucket (or wherever) and then upload build/server as a CF Worker.
— You are receiving this because you authored the thread. Reply to this email directly, https://github.com/lukeed/svelte-ssr-worker/issues/2#issuecomment-729162588, or https://github.com/notifications/unsubscribe-auth/ABCQBRLRDMV3XIDSX44ZZYLSQLHWHANCNFSM4TYR6FDA.
Oh, sorry 🙈 I linked you to old example.
Since you're likely using styles, you need to install @freshie/plugin.postcss
and postcss@7.0.32
.
Here's the same example, but running PostCSS and TypeScript. Note that you don't actually need to use/setup any PostCSS plugins if you don't want – it's just there to handle CSS output.
Okay! That works. Last question... Where do you put the CDN information for the bucket?
Questions are fine – no docs after all 😆
You create a freshie.config.js
in your project root (next to package.json
) and add a exports.publicPath
key, which defaults to /
and gets prepended to all your asset requests.
So if your CDN is going to be at https://static.example.com
then your file should have this:
// freshie.config.js
exports.publicPath = function (config, context) {
return context.isProd ? 'https://static.example.com/' : '/';
}
Works great! Wow, this is so simple to use!
Nice work!
Closing since I think you've migrated over to freshie
😉
Looks like the preload is working but not all the urls are updating!
Those are found in your src/index.html
template - which is not currently updated. Synchronizing those paths with publicPath
is on the todo list.
You can add the https://.../
path to your HTML template directly for the time being. I'll try to add that fix in today at lunch
@sandman18 Upgrading to freshie@0.0.8
fixes this. You can leave items like link ... href="/style.css"
in your HTML template & it will be synchronized for you.
Is this set up possible with navigation? Would you use something like navaid or would you redirect each /page through the cloudflare worker and point it to the corresponding folder on the bucket?
Thanks!