@skivvy/skivvy-package-browserify

    0.1.4 • Public • Published

    Skivvy package: browserify

    npm version Stability Build Status

    Compile JavaScript using Browserify

    Installation

    skivvy install browserify

    Overview

    This package allows you to compile JavaScript using Browserify from within the Skivvy task runner.

    Included tasks

    browserify

    Compile JavaScript using Browserify

    Usage:

    skivvy run browserify

    Configuration settings:

    Name Type Required Default Description
    source string Array<string> Yes N/A Path to source files
    destination string Yes N/A Path to compiled output file
    options object No {} Browserify API options
    options.watch boolean object No false Whether to watch source files for changes using watchify
    options.minify boolean object No false Whether to minify JS output using the uglifyify transform
    options.env string object No null Set environment variables and enable envify transform
    options.babelify boolean object No false Whether to transform JS output using the babelify transform
    options.require Array<string,object> No [] Files to make available outside the bundle
    options.external Array<string> No [] Prevent files from being loaded into the current bundle
    options.ignore Array<string> No [] Prevent files from showing up in the output bundle (return {} when required)
    options.exclude Array<string> No [] Prevent files from showing up in the output bundle (throw an error when required)
    options.transform Array<string,object,function> No [] Browserify transforms
    options.plugin Array<string,object,function> No [] Browserify plugins
    Notes:
    • If the watch configuration setting is a key/value object, that object will be passed as the watchify() function's opts argument

    • If the minify configuration setting is a key/value object, that object will be used as the UglifyJS2 options

    • If the env configuration setting is a string, process.env.NODE_ENV will be set to that value. If it is a key/value object, all the contained values will be assigned to process.env as environment variables

    • If the babelify configuration setting is a key/value object, that object will be used as the babelify options

    • options.require is an array files to make available outside the bundle and any associated options:

      [
          "./vendor/jquery/jquery.js",
          "./vendor/d3/d3.js",
          {
              "file": "./vendor/angular/angular.js",
              "options": { "expose": "angular" }
          }
      ]

      Each entry in options.require will be passed to the b.require() method.

    • options.external is an array of filenames that are prevented from being loaded into the current bundle:

      [
          "./external/foo.js",
          "./external/bar.js"
      ]

      Each entry in options.external will be passed to the b.external() method.

    • options.ignore is an array of filenames that are prevented from showing up in the output bundle:

      [
          "./hidden/foo.js",
          "./hidden/bar.js"
      ]

      Each entry in options.ignore will be passed to the b.ignore() method.

    • options.exclude is an array of filenames that are prevented from showing up in the output bundle:

      [
          "./hidden/foo.js",
          "./hidden/bar.js"
      ]

      Each entry in options.exclude will be passed to the b.exclude() method.

    • options.transform is an array of Browserify transforms and any associated options:

      [
          "brfs",
          "envify",
          {
              "transform": "babelify",
              "options": { "nonStandard": false, "comments": false }
          }
      ]

      If configuration is being set programmatically, transforms can also be specified as functions instead of strings.

      Each entry in options.transforms will be passed to the b.transform() method.

    • options.plugin is an array of Browserify plugins and any associated options:

      [
          "my-plugin",
          "another-plugin",
          {
              "plugin": "factor-bundle",
              "options": { "outputs": [ "bundle/x.js", "bundle/y.js" ] }
          },
      ]

      If configuration is being set programmatically, plugins can also be specified as functions instead of strings.

      Each entry in options.plugin will be passed to the b.plugin() method.

    Returns:

    Stream.Writable The output stream that is written to the filesystem

    Install

    npm i @skivvy/skivvy-package-browserify

    DownloadsWeekly Downloads

    10

    Version

    0.1.4

    License

    ISC

    Last publish

    Collaborators

    • skivvy
    • timkendrick