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

rollup-plugin-terser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-terser

Rollup plugin to minify generated es bundle

  • 7.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.2M
increased by4.51%
Maintainers
1
Weekly downloads
 
Created

What is rollup-plugin-terser?

The rollup-plugin-terser package is a plugin for Rollup, a module bundler for JavaScript, which allows you to minify your JavaScript files using Terser. Minification is the process of removing unnecessary characters from code to reduce its size, thus improving load times in browsers. This plugin integrates Terser into the Rollup build process.

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

Minification

This feature allows you to minify your JavaScript files. The code sample shows how to include the terser plugin in the Rollup configuration to minify the output bundle.

import { terser } from 'rollup-plugin-terser';

export default {
  input: 'src/index.js',
  output: {
    file: 'bundle.min.js',
    format: 'iife'
  },
  plugins: [
    terser()
  ]
};

Compress Options

This feature allows you to specify Terser compress options to customize the minification process. In the code sample, the `drop_console` option is set to `true` to remove console logs from the output.

import { terser } from 'rollup-plugin-terser';

export default {
  // ... other rollup config
  plugins: [
    terser({
      compress: {
        drop_console: true
      }
    })
  ]
};

Mangle Options

This feature allows you to mangle property names matching a pattern to shorten the code. In the code sample, properties starting with an underscore are mangled.

import { terser } from 'rollup-plugin-terser';

export default {
  // ... other rollup config
  plugins: [
    terser({
      mangle: {
        properties: {
          regex: /^_/ 
        }
      }
    })
  ]
};

Source Maps

This feature allows you to generate source maps for the minified code, which can be useful for debugging purposes. The code sample demonstrates how to enable source map generation in the Rollup configuration.

import { terser } from 'rollup-plugin-terser';

export default {
  // ... other rollup config
  output: {
    // ... other output options
    sourcemap: true
  },
  plugins: [
    terser({
      sourceMap: true
    })
  ]
};

Other packages similar to rollup-plugin-terser

Keywords

FAQs

Package last updated on 04 Sep 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