-
-
Notifications
You must be signed in to change notification settings - Fork 579
Assets helpers are not CDN friendly #921
Comments
Hey @TankTheFrank, may Also, which are your suggestions to make buffalo CDN friendly? |
I forgot to add the fix proposal for the hardcoded path - add "/assets" as "basePath" in webpacker manifest plugin for the default template and remove it as a hardcoded prefix. |
I could be wrong but doesn't -e also adds the packed assets in the binary beside creating the archive? This increases the binary size significantly (esoecially with image assets) and pointless memory at run time when assets are not served from it. I tried a mix of -k -e and other options and I ended up either without migrations (running migrate did nothing) or with a large file size. The "solution" that seemed to work was to generate the assets, delete CSS, images, js etc from the public dir and build again with -k (skip asset generation). Hence the "no easy way" part. |
Got it, I don't think its on purpose that Also, thanks for the suggestion on the |
If It's mostly an issue with these two lines: https://github.com/gobuffalo/buffalo/blob/master/buffalo/cmd/build/assets.go#L24 A PR to fix it would be fantastic. |
For the prefix this should do it: generators/assets/webpack/templates/webpack.config.js.tmpl
render/template_helpers.go b/render/template_helpers.go
Basically the "/assets/" prefix is added to manifest.json entries when it's generated instead of being forced at runtime. |
I just tested the |
I took a look at it and that's the same I saw. |
* Fix #921: use webpack publicPath, instead of hard-coded "/assets/".
@stanislas-m was there any progress on this issue? Is there anything I could do to fix it? Apart from the CDN friendlyness this issue also prevents asset helpers being useful if the web-app should not run under the "/" path, but a different path, because it is behind some sort of ingress management. (see: https://gophers.slack.com/archives/C3MSAFD40/p1572282815126800) - where I also talked to @paganotoni |
Hi all, I am currently trying to extract the assets from the built binary like @TankTheFrank talked about in his first message. And it seems that I have the same problem: when I pass the "-e" option to the "buffalo build" command line, the assets are correctly zipped in a separate ".zip" file, but they seems to keep being in the binary (basically, the size of the binary doesn't change). It has to be noticed that I am in "production" mode. Do I miss something? Thanks in advance for your help! |
First
buffalo/render/template_helpers.go
Line 32 in 6a1497f
prepends "/assets" (hardcoded) to the urls from manifest.json making the assets template helpers ( javascriptTag, stylesheetTag, etc) unusable with assets served from a separate domain.
Second, I could not find a straight-forward way of building a binary that packs the "must have" files (templates, migrations, manifest.json) while leaving the bulk of assets from the "asset" directory (css, js, images) unpacked.
The text was updated successfully, but these errors were encountered: