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

terser-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terser-webpack-plugin

Terser plugin for webpack

  • 3.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is terser-webpack-plugin?

The terser-webpack-plugin is a plugin for webpack that uses Terser to minify JavaScript files. It can improve the performance of web applications by reducing the size of the JavaScript bundle, which decreases loading times for users. It also offers options for code compression, mangling, and potentially other optimizations that can be configured to suit various deployment needs.

What are terser-webpack-plugin's main functionalities?

Minification

This feature allows you to minify your JavaScript files, removing unnecessary whitespace, comments, and code. It helps in reducing the file size and improving load times for your web application.

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin()],
  },
};

Source Map Support

This feature enables the generation of source maps, which help in debugging minified JavaScript by mapping the minified code back to the original source code.

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin({
      sourceMap: true,
    })],
  },
};

Code Compression

This feature allows for further compression of the JavaScript code, such as removing console logs and other statements that are not needed in production code.

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin({
      terserOptions: {
        compress: {
          drop_console: true,
        },
      },
    })],
  },
};

Mangling

Mangling reduces the size of your code by shortening the names of variables and functions to single characters. This feature is particularly useful for reducing the size of large codebases.

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin({
      terserOptions: {
        mangle: true, // Note: `mangle` is `true` by default.
      },
    })],
  },
};

Other packages similar to terser-webpack-plugin

Keywords

FAQs

Package last updated on 13 Jun 2020

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