[![Code Climate](https://img.shields.io/codeclimate/maintainability/envygeeks/jekyll-assets.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-assets/maintainability) [![Code Climate](https://img.shields.io/codeclimate/coverage/github/envygeeks/jekyll-assets.svg?style=for-the-badge)](https://codeclimate.com/github/envygeeks/jekyll-assets/test_coverage) [![Travis branch](https://img.shields.io/travis/envygeeks/jekyll-assets/master.svg?style=for-the-badge)](https://travis-ci.org/envygeeks/jekyll-assets) [![Donate](https://img.shields.io/badge/DONATE-USD-green.svg?style=for-the-badge)](https://envygeeks.io#donate) [![Gem](https://img.shields.io/gem/v/jekyll-assets.svg?style=for-the-badge)]() # Jekyll Assets Jekyll Assets is a drop in [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) that uses [Sprockets](https://github.com/rails/sprockets) to build specifically for Jekyll. It utilizes [Sprockets](https://github.com/rails/sprockets), and [Jekyll](https://jekyllrb.com) to try and achieve a clean and extensible assets platform that supports plugins, caching, converting your assets, and even the proxy of said assets in a way that does not interfere with either [Sprockets](https://github.com/rails/sprockets), or [Jekyll](3), and your own source. By default you can add Jekyll Assets to your Gemfile, as a plugin, and have it act as a drop-in replacement for Jekyll's basic SASS/CoffeeScript processors, with you only having to add it to your Gemfile, and updating your ``, and ``. ## Using Jekyll Assets with Jekyll ```ruby gem "jekyll-assets", group: :jekyll_plugins gem "jekyll-assets", git: "https://github.com/envygeeks/jekyll-assets", group: :jekyll_plugins gem "jekyll-assets", "~> x.x.alpha", group: :jekyll_plugins ``` ### Requirments * Ruby ***2.3+*** * Jekyll ***3.5+*** * Sprockets ***3.3+*** ***If you would like SourceMap support, or faster Sprockets, you should prefer to use Sprockets "~> 4.0.beta", we support SourceMaps in this version of Sprockets because it supports them. It's manifest an other features are also much better inside of this version of Sprockets.*** ```ruby gem "sprockets", "~> 4.0.beta", { require: false } ``` ## Configuration The configuration file is the same as Jekyll's, which is `_config.yml`. Except we use the special key "assets" inside of that file. Any environment variable noted as "val on `JEKYLL_ENV`" is only overridden when not explicitly set. All values listed below are default, you need not copy these into your configuration file unless you plan to change a value. ```yaml digest: false source_maps: true # false on JEKYLL_ENV=production destination: "/assets" compression: true gzip: false defaults: js: { integrity: false } # true on JEKYLL_ENV=production css: { integrity: false } # true on JEKYLL_ENV=production img: { integrity: false } # true on JEKYLL_ENV=production caching: path: ".jekyll-cache/assets" type: file # Possible values: memory, file enabled: true precompile: [] cdn: baseurl: false destination: false url: null sources: - assets/css - assets/fonts - assets/images - assets/videos - assets/javascript - assets/video - assets/image - assets/img - assets/js - _assets/css - _assets/fonts - _assets/images - _assets/videos - _assets/javascript - _assets/video - _assets/image - _assets/img - _assets/js - css - fonts - images - videos - javascript - video - image - img - js plugins: css: { autoprefixer: {}} img: { optim: {}} ``` ## Tag ### Usage #### Liquid ```liquid {% asset src @magick:2x alt='This is my alt' %} {% asset src @magick:2x alt='This is my alt' %} ``` #### HTML ```html This is my alt This is my alt ``` ### Defaults We provide several defaults that get set when you run an asset, depending on content type, this could be anything from type, all the way to integrity. If there is a default attribute you do not wish to be included, you can disable the attribute with `!attribute`, and it will be skipped over. #### Usage ```liquid {% asset img.png !integrity %} {% asset bundle.css !type %} ``` ### Arguments Our tags will take any number of arguments, and convert them to HTML, and even attach them to your output if the HTML processor you use accepts that kind of data. ***This applies to anything but hashes, and arrays.*** So adding say, a class, or id, is as easy as doing `id="val"` inside of your tag arguments. #### Builtins | Arg | Description | Type | Return Type | |---|---|---|---| | `@path` | Path | `*/*` | `text` | `@data` | `data` URI | `*/*` | `text` | | `@inline` | CSS `