1.0.1 • Published 5 years ago

@john-yuan/dev-browserify-builder v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Browserify Builder

A dev-tool to bundle the javascript file and its dependencies with browserify and minify the result code with uglify-js.

Install

npm i @john-yuan/dev-browserify-builder

Usage

var builder = require('@john-yuan/dev-browserify-builder');

builder.build('src/main.js', 'dist/main.min.js', {
    // The browserify options
    debug: false,
    detectGlobals: false
}, {
    // The uglify-js options
    compress: {
        drop_console: true
    }
}, function (code) {
    // Build finish callback
});

API

/**
 * Bundle the entry javascript file and its dependencies and minify the result.
 *
 * @param {string} entry The entry javascript file path
 * @param {string} output The path to save the result file
 * @param {Object} browserifyOptions The options passed to browserify
 * @param {Object} uglifyOptions The options passed to uglify-js
 * @param {(code: string) => void} callback The build finish callback, `code` is the final result
 */
builder.build(entry, output, browserifyOptions, uglifyOptions, callback);