UNPKG

1.88 kBMarkdownView Raw
1[npm]: https://img.shields.io/npm/v/@rollup/plugin-terser
2[npm-url]: https://www.npmjs.com/package/@rollup/plugin-terser
3[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-terser
4[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-terser
5
6[![npm][npm]][npm-url]
7[![size][size]][size-url]
8[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
9
10# @rollup/plugin-terser
11
12🍣 A Rollup plugin to generate a minified bundle with terser.
13
14## Requirements
15
16This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v2.0+.
17
18## Install
19
20Using npm:
21
22```console
23npm install @rollup/plugin-terser --save-dev
24```
25
26## Usage
27
28Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
29
30```typescript
31import terser from '@rollup/plugin-terser';
32
33export default {
34 input: 'src/index.js',
35 output: {
36 dir: 'output',
37 format: 'cjs'
38 },
39 plugins: [terser()]
40};
41```
42
43Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
44
45## Options
46
47The plugin accepts a terser [Options](https://github.com/terser/terser#minify-options) object as input parameter,
48to modify the default behaviour.
49
50In addition to the `terser` options, it is also possible to provide the following options:
51
52### `maxWorkers`
53
54Type: `Number`<br>
55Default: `undefined`
56
57Instructs the plugin to use a specific amount of cpu threads.
58
59```typescript
60import terser from '@rollup/plugin-terser';
61
62export default {
63 input: 'src/index.js',
64 output: {
65 dir: 'output',
66 format: 'cjs'
67 },
68 plugins: [
69 terser({
70 maxWorkers: 4
71 })
72 ]
73};
74```
75
76## Meta
77
78[CONTRIBUTING](/.github/CONTRIBUTING.md)
79
80[LICENSE (MIT)](/LICENSE)