Sha256: abb89c1795674d096d04518ca505238c369f425ce0cf5edefbb047c6a2cb78ec

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

# Frozen-string-literal: true
# Copyright: 2012 - 2018 - MIT License
# Encoding: utf-8

module Jekyll
  module Assets
    module Plugins
      Hook.register :asset, :after_compression, priority: 3 do |i, o, t|
        next unless t == "text/css"

        env = i[:environment]
        asset = env.find_asset!(i[:filename], pipeline: :source)
        path = asset.filename.sub(env.jekyll.in_source_dir + "/", "")
        url = SrcMap.map_path(asset: asset, env: env)
        url = env.prefix_url(url)

        o.update({
          data: <<~CSS
            #{o[:data].strip}
            /*# sourceMappingURL=#{url} */
            /*# sourceURL=#{path} */
          CSS
        })
      end

      # --
      Hook.register :env, :after_init, priority: 1 do
        next if asset_config[:compression]
        if asset_config[:source_maps]
          then asset_config[:compression] = true
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jekyll-assets-3.0.12 lib/jekyll/assets/plugins/srcmap/css.rb
jekyll-assets-3.0.11 lib/jekyll/assets/plugins/srcmap/css.rb
jekyll-assets-3.0.10 lib/jekyll/assets/plugins/srcmap/css.rb
jekyll-assets-3.0.9 lib/jekyll/assets/plugins/srcmap/css.rb
jekyll-assets-3.0.8 lib/jekyll/assets/plugins/srcmap/css.rb