vesselinv / fuel-sprockets

Asset management and asset bundling package for FuelPHP
MIT License
16 stars 7 forks source link

Ability to set base_url or root_url for asset tag render #2

Closed dmyers closed 11 years ago

dmyers commented 11 years ago

When rending the tags for js/css it currently just uses the asset_path which works locally, but it would be very useful to have the ability to use the base_url or root_path prepended to the asset_path.

So currently it would output something like: /assets/js/application.js

But this feature would be a new config and when set you could do: http://yoursite.com/assets/js/application.js

For me I use a CDN on production and made up hostname on my local dev.

It looks like this line handles the generating the asset tags, however this class doesn't have access to the config as far as I can tell: https://github.com/vesselinv/fuel-sprockets/blob/master/classes/sprockets/cache.php#L172

vesselinv commented 11 years ago

I can add a default config option 'base_url' => \Uri::base(false) . I think that's what you're after. So let's say for example the bundle file will be accessible at http://mycdn.com/somesubfolder/assets/js/application.js and it will be referenced correctly in the include tag by setting 'base_url' to http://mycdn.com/somesubfolder/. Yet, the asset_compile_dir will still need to be a physical path.

dmyers commented 11 years ago

That is exactly what I was thinking. That was fast! Thanks man. You made a great package and I'm working on adding it to my app Hubnotify. :)

I guess you have a ROR background. I'm curious what got you into FuelPHP. :D

vesselinv commented 11 years ago

Glad to hear it :)

I'm still a rookie when it comes to Rails. But what really got me into FuelPHP is that I found it very intuitive :)