GithubHelp home page GithubHelp logo

tairyu / globify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from js-devtools/globify

0.0 2.0 0.0 41 KB

Run browserify and watchify with globs - even on Windows!

License: MIT License

JavaScript 100.00%

globify's Introduction

Globify

Run browserify and watchify with globs - even on Windows!

Build Status Windows Build Status

Dependencies Coverage Status Code Climate Score Codacy Score Inline docs

npm License

Features

  • Supports glob patterns for entry files - even on Windows
  • Optionally create separate browserify bundles for each entry file

Related Projects

Installation

Install using npm. Add the -g flag to install globally so you can use it from any terminal.

npm install -g globify

Usage

The command-line interface is identical to browserify and watchify. In fact, globify simply passes your arguments straight to browserify or watchify (after expanding the glob pattern).

globify <entry files glob>  [options]

Options:

  <entry files glob>

    Glob pattern of entry files. Don't forget to wrap the glob pattern in quotes,
    otherwise some shells (like bash) will pre-expand the glob.

  --outfile=FILE, -o FILE

    If outfile is a file, then a single bundle will be created.  If it's a directory,
    then separate bundles will be created for each entry file.  You can also specify
    an output filename pattern, like *.bundled.js

  --exclude=GLOB, -u GLOB

    Excludes files that are matched by the <entry files glob>

  --watch, -w

    Call watchify instead of browserify.

Examples

For all of these examples, assume that we have a file structure like this:

lib/
 |__ my-entry-file.js
 |__ some-file.js
 |__ other-file.js
 |__ other-entry-file.js
 |__ subdir/
       |__ another-entry-file.js
       |__ another-file.js
       |__ yet-another-file.js

Multiple files in one bundle

We want to bundle all three entry files into a single bundle file. We can do that with the following command:

globify "lib/**/*-entry-file.js" --outfile=dist/my-bundle.js

Globify will call browserify once, passing it the three matching entry files and one bundle file:

browserify lib/my-entry-file.js lib/other-entry-file.js lib/subdir/another-entry-file.js --outfile=dist/my-bundle.js

Multiple files, multiple bundles

We want to create separate bundle files for each of the three entry files. We can do that with the following command:

globify "lib/**/*-entry-file.js" --outfile=dist

Globify will call browserify three times (once for each entry file), and create three corresponding bundles:

browserify lib/my-entry-file.js --outfile=dist/my-entry-file.js
browserify lib/other-entry-file.js --outfile=dist/other-entry-file.js
browserify lib/subdir/another-entry-file.js --outfile=dist/subdir/another-entry-file.js

Multiple files, multiple bundles with customized names

We want to create separate bundle files for each of the three entry files, but we weant each bundle file to have a .bundled.js suffix. We can do that with the following command:

globify "lib/**/*-entry-file.js" -o "dist/*.bundled.js"

Globify will call browserify three times (once for each entry file) and create three corresponding bundles:

browserify lib/my-entry-file.js -o dist/my-entry-file.bundled.js
browserify lib/other-entry-file.js -o dist/other-entry-file.bundled.js
browserify lib/subdir/another-entry-file.js -o dist/subdir/another-entry-file.bundled.js

Watchify, transforms, other options

Now, let's try it with watchify instead. Let's also add some extra options, and run the uglifyify transforms to minify the bundles. And let's give the bundles a .bundled.min.js suffix.

globify -g uglifyify "lib/**/*-entry-file.js" -w -v -d -o "dist/*.bundled.min.js"

Globify will call watchify (because of the -w option) three times with all of the specified options:

watchify -g uglifyify lib/my-entry-file.js -v -d -o dist/my-entry-file.bundled.min.js
watchify -g uglifyify lib/other-entry-file.js -v -d -o dist/other-entry-file.bundled.min.js
watchify -g uglifyify lib/subdir/another-entry-file.js -v -d -o dist/subdir/another-entry-file.bundled.min.js

Contributing

I welcome any contributions, enhancements, and bug-fixes. File an issue on GitHub and submit a pull request.

Building/Testing

To build/test the project locally on your computer:

  1. Clone this repo
    git clone https://github.com/BigstickCarpet/globify.git

  2. Install dependencies
    npm install

  3. Run the build script
    npm run build

  4. Run the unit tests
    npm run mocha (just the tests)
    npm test (tests + code coverage)

License

Globify is 100% free and open-source, under the MIT license. Use it however you want.

globify's People

Contributors

jamesmessinger avatar

Watchers

 avatar  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.