Skip to content

grimen/guard-packr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GUARD-PACKR alpha

Guard::Packr automatically compresses/obfuscates javascript files when modified (using Guard + Packr).

Installation

Add to your Gemfile:

  gem 'guard-packr'

…and bundle install.

Dependencies:

…you will need, but installed by Bundler they will be. – Yoda

Setup

Use the Guard generator:

  $ guard init packr

…to generate default Packr-guard (with notes) into your Guardfile

Usage

In your Guardfile, something like:

  guard 'packr', :extension => '.packed.js', :shrink_vars => true, :private => true, :base62 => false, :protect => %w[_this that] do
    # == IMPORTANT:
    #
    #   - Ensure that you don't write rules that owerwrite your source files!
    #     To avoid that either use custom "extension" (see above), or temporarily
    #     generated files as source (e.g. app/assets/javascripts => tmp/javascripts).
    #
    #   - This guard should be placed after any javascript processing (guard-sprockets, guard-jammit, etc.)
    #     within your Guardfile - naturally (Packr makes no sense for pre-processing javascript).
    #
    watch('tmp/javascripts/.*\.js')
  end

To read more about the Packr-options, see Packr.

When in doubt, see Guard.

Options

  :extension    => '.packed.js'     # File-extension for the packed javascript file.
  :shrink_vars  => true,            # Compress local variable names.
  :private      => true,            # Obfuscate 'private' identifiers, i.e. names beginning with a single underscore.
  :base62       => false,           # Encode the program using base 62.
  :protect      => %w[_this that]   # Variable names to protect from compression.

Notes

This gem was developed for a tiny special case at Merchii, so feel free to send pull-requests with enhancements of any kind (features, bug-fixes, documentation, tests, etc.) to make it better or useful for you as well.

License

Released under the MIT license.
Copyright © Merchii, Jonas Grimfelt

About

Guard for javascript compession/obfuscation using Packr. NOTE: Not maintained.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages