Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

uglifyjs-3-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uglifyjs-3-webpack-plugin

UglifyJS plugin for webpack

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
399
increased by12.08%
Maintainers
1
Weekly downloads
 
Created
Source

npm node deps test coverage chat

UglifyJS Webpack Plugin

This plugin uses UglifyJS v3 to minify your JavaScript

Install

npm i -D uglifyjs-3-webpack-plugin

Usage

webpack.config.js

const UglifyJsPlugin = require('uglifyjs-3-webpack-plugin')

module.exports = {
  plugins: [
    new UglifyJsPlugin()
  ]
}

Options

NameTypeDefaultDescription
test{RegExp|Array<RegExp>}/\.js$/iTest to match files against
include{RegExp|Array<RegExp>}undefinedFiles to include
exclude{RegExp|Array<RegExp>}undefinedFiles to exclude
cache{Boolean|String}falseEnable file caching
parallel{Boolean|Number}falseUse multi-process parallel running to improve the build speed
sourceMap{Boolean}falseUse source maps to map error message locations to modules (This slows down the compilation) ⚠️ cheap-source-map options don't work with this plugin
uglifyOptions{Object}{...defaults}uglify Options
extractComments{Boolean|RegExp|Function<(node, comment) -> {Boolean|Object}>}falseWhether comments shall be extracted to a separate file, (see details (webpack >= 2.3.0)
warningsFilter{Function(source) -> {Boolean}}() => trueAllow to filter uglify warnings

test

webpack.config.js

[
  new UglifyJsPlugin({
    test: /\.js($|\?)/i
  })
]

include

webpack.config.js

[
  new UglifyJsPlugin({
    include: /\/includes/
  })
]

exclude

webpack.config.js

[
  new UglifyJsPlugin({
    exclude: /\/excludes/
  })
]

cache

{Boolean}

webpack.config.js

[
  new UglifyJsPlugin({
    cache: true
  })
]

Enable file caching. Default path to cache directory: node_modules/.cache/uglifyjs-webpack-plugin.

{String}

webpack.config.js

[
  new UglifyJsPlugin({
    cache: 'path/to/cache'
  })
]

Path to cache directory.

parallel

{Boolean}

webpack.config.js

[
  new UglifyJsPlugin({
    parallel: true
  })
]

Enable parallelization. Default number of concurrent runs: os.cpus().length - 1.

{Number}

webpack.config.js

[
  new UglifyJsPlugin({
    parallel: 4
  })
]

Number of concurrent runs.

ℹ️ Parallelization can speedup your build significantly and is therefore highly recommended

sourceMap

webpack.config.js

[
  new UglifyJsPlugin({
    sourceMap: true
  })
]

⚠️ cheap-source-map options don't work with this plugin

uglifyOptions

NameTypeDefaultDescription
warnings{Boolean}falseDisplay Warnings
parse{Object}{}Additional Parse Options
compress{Boolean|Object}trueAdditional Compress Options
mangle{Boolean|Object}trueEnable Name Mangling (See Mangle Properties for advanced setups, use with ⚠️)
output{Object}{}Additional Output Options (The defaults are optimized for best compression)
toplevel{Boolean}falseEnable top level variable and function name mangling and to drop unused variables and functions
nameCache{Object}nullEnable cache of mangled variable and property names across multiple invocations
ie8{Boolean}falseEnable IE8 Support
keep_fnames{Boolean}falseEnable prevent discarding or mangling of function names. Useful for code relying on Function.prototype.name.

webpack.config.js

[
  new UglifyJsPlugin({
    uglifyOptions: {
      warnings: false,
      parse: {...options},
      compress: {...options},
      mangle: {
        ...options,
        properties: {
          // mangle property options
        }
      },
      output: {
        comments: false,
        beautify: false,
        ...options
      },
      toplevel: false,
      nameCache: null,
      ie8: false,
      keep_fnames: false,
    }
  })
]

extractComments

{Boolean}

All comments that normally would be preserved by the comments option will be moved to a separate file. If the original file is named foo.js, then the comments will be stored to foo.js.LICENSE.

{RegExp|String} or {Function<(node, comment) -> {Boolean}>}

All comments that match the given expression (resp. are evaluated to true by the function) will be extracted to the separate file. The comments option specifies whether the comment will be preserved, i.e. it is possible to preserve some comments (e.g. annotations) while extracting others or even preserving comments that have been extracted.

{Object}
NameTypeDefaultDescription
condition{Regex|Function}``Regular Expression or function (see previous point)
filename{String|Function}${file}.LICENSEThe file where the extracted comments will be stored. Can be either a {String} or a {Function<(string) -> {String}>}, which will be given the original filename. Default is to append the suffix .LICENSE to the original filename
banner{Boolean|String|Function}/*! For license information please see ${filename}.js.LICENSE */The banner text that points to the extracted file and will be added on top of the original file. Can be false (no banner), a {String}, or a {Function<(string) -> {String} that will be called with the filename where extracted comments have been stored. Will be wrapped into comment

warningsFilter

webpack.config.js

[
  new UglifyJsPlugin({
    warningsFilter: (src) => true
  })
]

Maintainers


Steven Hargrove

Juho Vepsäläinen

Joshua Wiens

Michael Ciniawsky

Alexander Krasnoyarov

Keywords

FAQs

Package last updated on 12 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc