Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

snowpack-plugin-terser

jaredLunde12MIT0.1.0TypeScript support: included

Use Terser to minify JavaScript in production Snowpack apps

snowpack plugin terser, snowpack plugin, terser

readme


snowpack-plugin-terser

Use Terser to minify JavaScript in production Snowpack apps

# NOTE: terser is a peer dependency
npm i terser snowpack-plugin-terser

Types Build status NPM Version MIT License


Why do this?

While Snowpack has a minify option built in, it only uses esbuild's minification. In doing so it misses many optimizations that are caught by Terser.

When to use this

You should only use this if you aren't already using a bundler (Webpack, Parcel, Rollup) to build your production site.

Quick start

// snowpack.config.js
module.exports = {
  buildOptions: {
    minify: false,
  },
  plugins: [
    [
      'snowpack-plugin-terser',
      {
        /**
         * @see Plugin Options below
         */
        terserOptions: {
          compress: {
            arguments: true,
            passes: 2,
            unsafe_arrows: true,
          },
        },
      },
    ],
  ],
}

Plugin Options

export interface SnowpackPluginTerserOptions {
  /**
   * An array of glob patterns for files you want to explicitly include
   * for Terser minification. By default, all JavaScript files are included.
   */
  include?: string[]
  /**
   * An array of glob patterns for files you want to exclude from
   * Terser minification
   */
  exclude?: string[]
  /**
   * Terser minify() options passed directly to Terser
   * @see https://github.com/terser/terser#minify-options
   *
   * @default {
   *   module: true,
   *   toplevel: true,
   *   compress: {
   *     ecma: 2016,
   *   },
   *   format: {
   *     ecma: 2016
   *   }
   * }
   */
  terserOptions?: terser.MinifyOptions
}

LICENSE

MIT

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.1.0 (2020-08-27)

Features