amber icon indicating copy to clipboard operation
amber copied to clipboard

[Assets] Asset helper w/ cached assets

Open JoshJuncker opened this issue 7 years ago • 8 comments

It seems that Amber currently lacks a default convention for caching/versioning bundled assets as well as referencing those cached assets from views (think sprockets in rails). Since Amber already relies on webpack, it would make sense to configure webpack for caching/fingerprinting in production and set up a crystal asset helper that is included in views to easily reference these files (ex. javascript_pack_tag, stylesheet_pack_tag, asset_pack_path, asset_pack_url).

A good reference for doing so would be https://github.com/rails/webpacker, however it obviously doesn't have to be the exact same. It still allows configuration/customization, but comes with a preferred set of defaults out of the box.

JoshJuncker avatar Jan 20 '18 22:01 JoshJuncker

@JoshJuncker thanks for the good suggestion.

Would you mind opening a PR with the proposed changes, I think is a good contribution

eliasjpr avatar Jan 21 '18 15:01 eliasjpr

@eliasjpr what do you think of putting code / functionality like this in external shards?

robacarp avatar Jan 22 '18 17:01 robacarp

@eliasjpr Would you guys want the program to fail to compile if you try to reference an asset that doesn't exist?

JoshJuncker avatar Jan 23 '18 18:01 JoshJuncker

I think it would probably make sense to build into amber since it depends on configuration in a generated amber project. Also the more shards were dependent on the more brittle our project becomes

elorest avatar Jan 23 '18 18:01 elorest

#574 will address this issue if someone wants to pickup the mantle and bring this home.

drujensen avatar Dec 24 '18 19:12 drujensen

@drujensen I can take a look, although I can't promise much! Do you know what needs doing? Is it mainly the conflicts?

jackturnbull avatar Jan 07 '19 20:01 jackturnbull

@jackturnbull That would be fantastic. There were several requested changes if I recall. Right now, just getting it working again would be the first step. Maybe fork @JoshJuncker branch?

drujensen avatar Jan 07 '19 21:01 drujensen

PR Raised: https://github.com/amberframework/amber/issues/555

jackturnbull avatar Feb 10 '19 21:02 jackturnbull