Skip to content
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

Navigation #2

Closed
rjsandman opened this issue Nov 17, 2020 · 10 comments
Closed

Navigation #2

rjsandman opened this issue Nov 17, 2020 · 10 comments

Comments

@rjsandman
Copy link

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!

@lukeed
Copy link
Owner

lukeed commented Nov 17, 2020

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.

@rjsandman
Copy link
Author

rjsandman commented Nov 18, 2020 via email

@lukeed
Copy link
Owner

lukeed commented Nov 18, 2020

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.

@rjsandman
Copy link
Author

Okay! That works. Last question... Where do you put the CDN information for the bucket?

@lukeed
Copy link
Owner

lukeed commented Nov 18, 2020

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/' : '/';
}

@rjsandman
Copy link
Author

Works great! Wow, this is so simple to use!

Nice work!

@lukeed
Copy link
Owner

lukeed commented Nov 20, 2020

Closing since I think you've migrated over to freshie 😉

@lukeed lukeed closed this as completed Nov 20, 2020
@rjsandman
Copy link
Author

Looks like the preload is working but not all the urls are updating!
Screen Shot 2020-11-20 at 2 17 08 PM

@lukeed
Copy link
Owner

lukeed commented Nov 20, 2020

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

@lukeed
Copy link
Owner

lukeed commented Nov 20, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants