Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ender-minify

ender-js170.1.1

Interface to UglifyJS Closure Compiler and YUICompressor

minify, uglify, yuicompressor, closure

readme

ender-minify

Bundled minifier utilities for Node, designed primarily for use with the Ender CLI.

UglifyJS

var fs = require('fs')
var em = require('ender-minify')
var options = {} // no options for UglifyJS at the moment

fs.readFile('source.js', 'utf-8', function (err, source) {
  if (err) throw err

  em.minify('uglify', source, options, function (err, minifiedSource) {
    if (err) throw err

    fs.writeFile('source.min.js', minifiedSource, 'utf-8')
  })
})

Closure Compiler

var fs = require('fs')
var em = require('ender-minify')
var options = {
  level: 'simple',                 // can be 'whitespace', 'simple' or 'advanced'
  externs: [ 'foo.js', 'bar.js' ]  // passed as --externs
}

fs.readFile('source.js', 'utf-8', function (err, source) {
  if (err) throw err

  em.minify('closure', source, options, function (err, minifiedSource) {
    if (err) throw err

    fs.writeFile('source.min.js', minifiedSource, 'utf-8')
  })
})

YUICompressor coming soon...