orchidhq / Orchid

Build and deploy beautiful documentation sites that grow with you
https://orchid.run
GNU General Public License v3.0
512 stars 53 forks source link

Font Awesome not retrieved from CDN in Production env #366

Closed bjansen closed 4 years ago

bjansen commented 4 years ago

Hi,

I made a website based off OrchidStarter and changed the theme to BsDoc. When I deploy the content to my prod env, all the external assets are downloaded locally and "embedded" inside the generated content, even those CSS files that include relative path to fonts that are not embedded.

Expected: the Font Awesome CSS can download the fonts Actual: the site ships with the CSS but not the fonts, so I get 404 errors

In BsDocTheme.kt I can see this comment:

// these assets include relative references to font files, which become invalid if the asset it downloaded locally and so need to stay as external assets even in production
addCss(CssPage(this, "theme", context.getResourceEntry("https://netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css", null), "bootstrap.min", null))
...

But I'm not sure if's a TODO or if it describes what Orchid really does (i.e. don't download these scripts).

Does it work out of the box and did I break something when I modified the starter kit?

Thanks for your help.

cjbrooks12 commented 4 years ago

It's a known issue, but one that I don't really have a good idea of how to properly handle right now, because Orchid doesn't recursively fetch included files when downloading them in production. Tt just downloads the one file.

To keep it from breaking prod builds, the snippet you pasted is a hack that just keeps those assets from being downloaded in prod builds. So if you do a similar thing to include FontAwesome, it will still reference it from a CDN, but it shouldn't break in prod builds.

bjansen commented 4 years ago

Font Awesome is one of the assets used in BsDocTheme, yet it was broken in my prod build.

cjbrooks12 commented 4 years ago

Oh, I see what you mean now. This is a regression, I'll have to dig a bit deeper to know what exactly changed, though. So sorry about that.

cjbrooks12 commented 4 years ago

This is now fixed and released in 0.21.0. Asset management, in general, has been refactored and greatly improved