Sha256: c197603733c275fa67639eabc78e3a6366d5c296b70ea4e1cc6547c286fcb097

Contents?: true

Size: 1.93 KB

Versions: 40

Compression:

Stored size: 1.93 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/uglify.rb
# Liquid filter for J1 Template to uglify JS
#
# Product/Info:
# http://jekyll.one
#
# Copyright (C) 2022 Juergen Adams
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
# ------------------------------------------------------------------------------
# => Uglifier.compile(File.read(input))
# ------------------------------------------------------------------------------
#  NOTE:
#  CustomFilters cannot be used in SAFE mode (e.g not usable for
#  rendering pages with Jekyll on GitHub
#
#  USAGE:
#    {% capture cache_name %}
#
#      liquid code to generate HTML output goes here
#
#    {% endcapture %}
#    {{ cache_name | uglify }}
# ------------------------------------------------------------------------------
# noinspection SpellCheckingInspection
# rubocop:disable Lint/UnneededDisable
# rubocop:disable Style/Documentation
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/TrailingWhitespace
# rubocop:disable Layout/SpaceAroundOperators
# rubocop:disable Layout/ExtraSpacing
# rubocop:disable Metrics/AbcSize
# ------------------------------------------------------------------------------
# NOTE: To be checked if the gem uglifier can be replaced by the
# JS module "Terser" already used for package 200_template_js
# ------------------------------------------------------------------------------
require 'uglifier'

module Jekyll
  module MinifyJS
    def minifyJS(input)
      # see: https://github.com/mishoo/UglifyJS/issues/495
      # quote_style 3 -- always use the original quotes
      minified = Uglifier.compile(input,
                    harmony: true,
                    :output => {
                        :quote_style => 3
                    }
                 )
      input = minified
    end
  end
end

Liquid::Template.register_filter(Jekyll::MinifyJS)

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
j1-template-2022.6.3 lib/starter_web/_plugins/filter/minifyJS.rb
j1-template-2022.6.2 lib/starter_web/_plugins/filter/minifyJS.rb
j1-template-2022.6.1 lib/starter_web/_plugins/filter/minifyJS.rb
j1-template-2022.6.0 lib/starter_web/_plugins/filter/minifyJS.rb
j1-template-2022.5.3 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.2 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.1 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.1.rc1 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.1.rc0 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.0 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.0.rc4 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.0.rc3 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.0.rc2 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.0.rc1 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.5.0.rc0 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.3.0.rc1 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.3.0.rc0 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.4.10 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.4.9 lib/starter_web/_plugins/minifyJS.rb
j1-template-2022.4.8 lib/starter_web/_plugins/minifyJS.rb