npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metalsmith-uglify

v2.4.2

Published

An uglify plugin for Metalsmith.

Downloads

2,327

Readme

Build Status Coverage Status

metalsmith-uglify

This is an UglifyJS plugin for Metalsmith and is a successor to the original plugin written by Keith Smith.

Usage

Install the package:

npm install metalsmith-uglify

Add the plugin to your Metalsmith build chain:

const metalsmith = require('metalsmith');
const uglify = require('metalsmith-uglify');

metalsmith(__dirname)
    .source('./src')
    .destination('./public')
    .use(uglify());
    .build(function (err) {
        if (err) {
            throw err;
        }

        console.log('Build complete');
    });

Options

The plugin function accepts a configuration object as the first argument.

  • {boolean} options.es - Set to use terser package instead of uglify-js. It will set also set options.uglify.ecma = 6 by default.

  • {object} options.concat - Set to concatenate to a single bundle file.

    • {string} options.concat.file - Name of the bundle file. Default is scripts.min.js.

    • {string} options.concat.root - Directory where the bundle file will be placed. This option overrides options.root.

  • {Array[string]} options.files - List of files to be processed. If options.concat is set, files will be passed to UglifyJS in that order. This option is only needed for bundling badly written code (e.g. jQuery) that relies on files being processed in a certain order. This option overrides options.filter.

  • {function} options.filter - Function to filter the list of JavaScript files. By default .min.js files are excluded.

  • {string} options.root - Set to limit the plugin to a specific source directory.

  • {boolean} options.removeOriginal - Set to exclude the original (unminified) file from the output directory.

  • {boolean} options.sameName - Set to keep minified name as is without adding .min. This option overrides options.removeOriginal and is ignored if options.concat is set.

  • {object} options.uglify - UglifyJS configuration (see UglifyJS docs). Default is { sourceMap: { includeSources: true } }.

  • {boolean} options.windows - Set this if you are using the plugin on Windows. If you are using any of the root options, you will need to use \\ instead of / in the path.

Upgrading from version 1.x

Version 2 is a rewrite of the plugin with significant breaking changes to the options object.

Please refer to the upgrade document for more information.

Example

To build the example page run:

make example

Inspect files in example/ for more information.

Debug Logging

Set the DEBUG variable to see what the plugin is doing.

If you are troubleshooting the plugin itself then the following should be enough:

DEBUG=metalsmith-uglify:info:* node build.js

If you think the problem is actually related to something UglifyJS does then you can get more detail:

DEBUG=metalsmith-uglify:* node build.js