GithubHelp home page GithubHelp logo

tssk / metalsmith-uglify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from borisovg/metalsmith-uglify

0.0 1.0 0.0 145 KB

UglifyJS plugin for Metalsmith

License: GNU Lesser General Public License v3.0

Makefile 10.05% JavaScript 86.58% HTML 1.87% CSS 1.50%

metalsmith-uglify's Introduction

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:

var metalsmith = require('metalsmith');
var 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 uglify-es 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. UglifyJS does not provide any ordering guarantees.

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

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

  • {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.

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

metalsmith-uglify's People

Contributors

altano avatar borisovg avatar ksmithut avatar zommerfelds avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.