Skip to content

Commit

Permalink
Update terser docs (#4710)
Browse files Browse the repository at this point in the history
The old package isn't compatible with rollup 3.x

Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
nikolas and lukastaegert committed Nov 11, 2022
1 parent e228fc7 commit ea36d8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/04-tutorial.md
Expand Up @@ -242,18 +242,18 @@ _Note: Only the data we actually need gets imported – `name` and `devDependenc

Some plugins can also be applied specifically to some outputs. See [plugin hooks](guide/en/#build-hooks) for the technical details of what output-specific plugins can do. In a nut-shell, those plugins can only modify code after the main analysis of Rollup has completed. Rollup will warn if an incompatible plugin is used as an output-specific plugin. One possible use-case is minification of bundles to be consumed in a browser.

Let us extend the previous example to provide a minified build together with the non-minified one. To that end, we install `rollup-plugin-terser`:
Let us extend the previous example to provide a minified build together with the non-minified one. To that end, we install `@rollup/plugin-terser`:

```
npm install --save-dev rollup-plugin-terser
npm install --save-dev @rollup/plugin-terser
```

Edit your `rollup.config.js` file to add a second minified output. As format, we choose `iife`. This format wraps the code so that it can be consumed via a `script` tag in the browser while avoiding unwanted interactions with other code. As we have an export, we need to provide the name of a global variable that will be created by our bundle so that other code can access our export via this variable.

```js
// rollup.config.js
import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser';
import terser from '@rollup/plugin-terser';

export default {
input: 'src/main.js',
Expand Down

0 comments on commit ea36d8b

Please sign in to comment.