metalsmith-uglifyjs
A very lightweight Metalsmith uglifyjs2 plugin
Last updated 3 years ago by ubenzer .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install metalsmith-uglifyjs 
SYNC missed versions from official npm registry.

metalsmith-uglifyjs

Gitter Travis David David Codecov npm npm

An Uglifyjs2 plugin for Metalsmith.

Installation

npm install --save metalsmith-uglifyjs

Getting Started

If you haven't checked out Metalsmith before, head over to their website and check out the documentation.

Usage

var uglifyjs = require("metalsmith-uglifyjs");

metalsmith
  .use(uglifyjs({
    src: ["**/*.js", "!**/*.min.js"],
    target: function(inFile) { return inFile + ".customMinFileName.js"; },
    deleteSources: true,
    uglifyOptions: {
      mangle: true,
      compress: {
        unused: false,
        warnings: true
      }
    }
  }))

Options

You can check the tests out to see some usage examples.

src

A multimatch expression that can be used to limit the files that will be uglified. Default is ["**/*.js", "!**/*.min.js"] Please note that IT IS YOUR JOB to EXCLUDE already minified files using src setting if you are using a customized name convention.

target

A function that takes a file name as input and expected to return minified file name as output. Default function adds .min. before extension. (i.e. a.js -> a.min.js)

override

If true, then compressed JS will be written into the same files that were compressed. The target and deleteSources options are discarded in this case.

Default: false

deleteSources

A boolean, if true original files will be deleted, if false original files will be kept as-is. Default: false

active

A boolean flag, when set to false this whole stuff will be disabled. This can be used to disable uglify based on some variable. (e.g. Don't run this on dev but run this on prod.)

Default: true

uglifyOptions

A valid config that will be passed to uglifyjs. Please see here for your options. Default:

uglifyOptions: {
  mangle: false,
  compress: {}
}

This means use default compress options and do not mangle.

Contributing

Just open an issue or prepare a pull request.

Current Tags

  • 0.2.3                                ...           latest (3 years ago)

13 Versions

  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           4 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 13
Dependencies (7)
Dev Dependencies (8)

Copyright 2014 - 2017 © taobao.org |