{
  "name": "uglify-save-license",
  "version": "0.4.1",
  "description": "License detector for UglifyJS",
  "main": "./uglify-save-license.js",
  "scripts": {
    "test": "grunt build"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/shinnn/uglify-save-license.git"
  },
  "author": {
    "name": "Shinnosuke Watanabe",
    "url": "https://github.com/shinnn"
  },
  "readmeFilename": "README.md",
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/shinnn/uglify-save-license/blob/master/LICENSE"
    }
  ],
  "keywords": [
    "uglify",
    "compression",
    "minification",
    "comment",
    "license",
    "copyright",
    "detection",
    "preservation",
    "banner"
  ],
  "bugs": {
    "url": "https://github.com/shinnn/uglify-save-license/issues"
  },
  "homepage": "https://github.com/shinnn/uglify-save-license",
  "devDependencies": {
    "grunt": "^0.4.4",
    "load-grunt-tasks": "^0.4.0",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-contrib-uglify": "^0.4.0",
    "grunt-contrib-clean": "^0.5.0",
    "grunt-contrib-nodeunit": "^0.3.3",
    "grunt-release": "^0.7.0",
    "grunt-replace": "^0.7.7",
    "semver": "^2.2.1"
  },
  "readme": "# uglify-save-license\n\n[![NPM version](https://badge.fury.io/js/uglify-save-license.svg)](http://badge.fury.io/js/uglify-save-license)\n[![Build Status](https://travis-ci.org/shinnn/uglify-save-license.svg)](https://travis-ci.org/shinnn/uglify-save-license)\n[![devDependency Status](https://david-dm.org/shinnn/uglify-save-license/dev-status.svg)](https://david-dm.org/shinnn/uglify-save-license#info=devDependencies)\n\nA support module for [UglifyJS](http://lisperator.net/uglifyjs/) to detect and preserve license comments\n\n```javascript\n//     Backbone.js 1.1.2\n\n//     (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n//     Backbone may be freely distributed under the MIT license.\n//     For all details and documentation:\n//     http://backbonejs.org\n\n(function(root, factory) {\n\n  // Set up Backbone appropriately for the environment. Start with AMD.\n  if (typeof define === 'function' && define.amd) {\n    define(['underscore', 'jquery', 'exports'], function(_, $, exports) {\n//...\n```\n\n↓\n\n```javascript\n//     Backbone.js 1.1.2\n//     (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n//     Backbone may be freely distributed under the MIT license.\n//     For all details and documentation:\n//     http://backbonejs.org\n!function(a,b){if(\"function\"==typeof define&&define.amd)define([\"underscore\",\"jquery\",\"exports\"],function(c,d,e){a.Backbone=b(a,e,c,d)});else if(\"undefined\"!=typeof exports){...\n```\n\n## Overview\n\nThis module enables us to preserve license comments when using UglifyJS.\n\nEven if the license statement is in multiple line comments, or the comment has no directive such as `@license` and `/*!`, this module keeps them readable.\n\n## Installation\n\nInstall with [npm](https://npmjs.org/). (Make sure you have installed [Node](http://nodejs.org/download/).)\n\n```\nnpm install --save-dev uglify-save-license\n```\n\n## Usage\n\nFirst of all, load `uglify-save-license` module.\n\n```javascript\nvar saveLicense = require('uglify-save-license');\n```\n\n### Use with [UglifyJS](https://github.com/mishoo/UglifyJS2)\n\nPass this module to the [`comments` option](https://github.com/mishoo/UglifyJS2#keeping-comments-in-the-output).\n\n```javascript\nvar result = UglifyJS.minify('file1.js', {\n  output: {\n    comments: saveLicense\n  }\n});\n```\n\n### Use with [grunt-contrib-uglify](https://github.com/gruntjs/grunt-contrib-uglify)\n\nPass this module to the [`preserveComments` option](https://github.com/gruntjs/grunt-contrib-uglify#preservecomments).\n\n```javascript\ngrunt.initConfig({\n  uglify: {\n    my_target: {\n      options: {\n        preserveComments: saveLicense\n      },    \n      src: ['src/app.js'],\n      dest: 'dest/app.min.js' \n    }\n  }\n});\n```\n\n## How it works\n\n*uglify-save-license* checks each [comment token](http://lisperator.net/uglifyjs/ast#tokens) of a JavaScript file.\nThe comment will be regarded as a license statement and preserved after compression, if it meets at least one of the following requirements:\n\n1. The comment is in the *first* line of a file.\n2. [The regexp for license statement](./uglify-save-license.js#L7) matches the string of the comment. It matches, for example, `MIT` and `Copyright`.\n3. There is a comment at the *previous* line, and it matches 1. 2. or 3.\n\n## Examples\n\n### CLI tool example\n\n#### Main script (`uglify-example.js`)\n\n```javascript\n#!/usr/bin/env node\n\nvar UglifyJS    = require('uglify-js'),\n    saveLicense = require('uglify-save-license');\n\nvar minified = UglifyJS.minify(process.argv[2], {\n  output: {\n    comments: saveLicense\n  }\n}).code;\n\nconsole.log(minified);\n```\n\n#### Target file\n\n```javascript\n// First line\n\n// (c) 2014 John  <- contains '(c)'\n// The previous line is preserved\n\n// This line won't be preserved.\n(function(win, doc) {\n  var str = 'Hello World! :' + doc.title;\n\n  // This line will not, too.\n  console.log(str);\n}(window, document));\n```\n\n#### Command\n\n```\nnode uglify-example.js <target filename>\n```\n\n#### Output\n\n```javascript\n// First line\n// (c) 2014 John  <- contains '(c)'\n// The previous line is preserved\n!function(o,l){var n=\"Hello World! :\"+l.title;console.log(n)}(window,document);\n```\n\n### [Gruntfile.coffee](http://gruntjs.com/getting-started#the-gruntfile) example\n\n```coffeescript\nmodule.exports = (grunt) ->\n\n  grunt.loadNpmTasks 'grunt-contrib-uglify'\n  grunt.loadNpmTasks 'grunt-contrib-concat'\n  grunt.loadNpmTasks 'grunt-contrib-clean'\n  \n  grunt.initConfig\n    uglify:\n      target:\n        options:\n          preserveComments: require 'uglify-save-license'\n        files: [\n          expand: true\n          flatten: true\n          cwd: 'path/to/src'\n          src: ['**/*.js']\n          dest: 'tmp/'\n        ]\n\n    concat:\n      js:\n        src: ['tmp/*.js']\n        dest: 'path/to/build/app.js'\n\n    clean:\n      tmpdir: ['tmp']\n\n  grunt.registerTask 'default' ['uglify', 'concat', 'clean']\n```\n\n## Acknowledgements\n\n*uglify-save-license* is inspired by [grunt-license-saver](https://github.com/kyo-ago/grunt-license-saver) and I used it as reference.\nThanks, [kyo-ago](https://github.com/kyo-ago).\n\n## License\n\nCopyright (c) 2013 - 2014 [Shinnosuke Watanabe](https://github.com/shinnn)\n\nLicensed under [the MIT license](./LICENSE).\n",
  "_id": "uglify-save-license@0.4.1",
  "_shasum": "95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1",
  "_from": "uglify-save-license@",
  "_resolved": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz"
}
