0.0
No commit activity in last 3 years
No release in over 3 years
A rake task for compressing assets with uglifier. It can also create source maps.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
>= 2.0.0
 Project Readme

rake-uglifier

A simple rake task for minifying assets and include optional source maps.

Installation

$ gem install rake-uglifier

Setup

Here is how you set it up:

require 'rake/uglifier_task'

# :minify is the name of the task
Rake::UglifierTask.new(:minify) do |t|
  t.assets_path      = File.join(File.dirname(__FILE__), 'public', 'assets')
  t.logger           = Logger.new($stdout)
  t.uglifier_options = {
    mangle: {
      except: %w($ jQuery someOtherGlobalVariable)
    }
  }
end

These are the different options:

# A Hash containing the options to give to uglifier
:uglifier_options

# The name of the task, defaults to :minify
:name

# The logger to use
:logger

# A list of regexps that should match any assets to compile
# Defaults to all file ending in .js
:assets

# A list of regexps to ignore
# Default to all minified files
:assets

# A booleaning indicating whether or not to create source maps
:create_source_map

# The path to the root directory where the assets are located.
:assets_path

Example Rakefile

The Rakefile in the repo is an example of a rakefile that can compile and minify assets.

License

This project is licensed under the MIT license, see LICENSE.txt for more info.

Changelog

  • 0.0.3
    • Add a way to ignore files
  • 0.0.2
    • Minor readme tweaks
    • Require uglifier 2.0
  • 0.0.1
    • Initial release