moshen / jekyll-asset_bundler

A small plugin for Jekyll to easily bundle and compress site assets
MIT License
101 stars 21 forks source link

Use a CDN if it's specified in the configuration. #2

Closed kellysutton closed 12 years ago

kellysutton commented 12 years ago

Just a new little configuration parameter:

asset_bundler: 
  cdn: //somecdn.cloudfront.net/

Will generate URLs that prepend the CDN URL.

moshen commented 12 years ago

Great idea. Will merge shortly.

kellysutton commented 12 years ago

Whoops, I might apply a patch to this. Right now, a CDN URL requires a slash at the end. I need to make it work regardless of the slash or not.

Also, it could check the root of _config.yml, but I'm not sure how encapsulated you want to make this. (Falling back to the root of _config.yml lets other plugins use the CDN URL as well. For example:

server_port:4000
cdn: https://my-cdn.cloudfront.net

vs.

server_port: 4000
asset_bundler:
  cdn: https://my-cdn.cloudfront.net
moshen commented 12 years ago

You could edit the self.config method to check the cdn option like I do for the dev option.

Also as far as a top-level option goes, I do the same thing with the dev option, but I did poke around in the existing plugins to see if it was used.

moshen commented 12 years ago

I've merged this locally and added a check on the base_path option to make sure that there's a preceding slash. This lets the cdn url setting work no matter what.

I will close after I push to master. I'm currently ignoring the root cdn option in _config.yml. Not sure if it's necessary. Does anyone else use it?