node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

wow-task-runner

WOW JavaScript Task Runner

WOW is a Convention Over Configuration task runner using Node.

just install the plugins and it compiles, minimizes, concatenates, etc.

Comes with watch and reload included.

Every compiled file has its source map.

Installation

npm install -g wow-task-runner

Modules

there are modules ready for many useful tasks

  • wow-clean-css: module for clean-css (disabled with: postcss)
  • wow-uglify-js: module for uglify-js
  • wow-less: compiles less
  • wow-sass: compiles sass
  • wow-html-minifier: module for html-minifier
  • wow-concat: concatenates javascript or css
  • wow-coffee-script: transpiles coffe-script
  • wow-typescript: transpiles typescript
  • wow-emscripten: compiles C or C++ to JavaScript with Emscripten
  • wow-postcss: module for PostCSS, configurable with postcss plugins (disables: clean-css)

Just install the modules you need

npm install -g wow-uglify-js wow-clean-css

Run

Start WOW in watch mode

In this mode WOW will listen for changes, and compile a file if it's source or one of the included files is modified.

By default WOW loads all modules named wow-* present in the local or in the global scope.

wow

Automatic reload

To enable automatic reload each time a compiled file loaded by the page is modified, include the following javascript.

<script async src="http://localhost:8000/reload"></script>

Start WOW in task mode

If you want to compile all the files matching a specific module run WOW with the names of the modules you've chosen.

e.g. this minimizes all the .js and .css in the current folder and subfolders.

wow uglify-js clean-css

A module can also expose tasks as functions, and they can be called this way:

e.g. if a module called wow-foo exports a function named bar

wow foo.bar.conf1 foo.bar.conf2=2

will call foo.bar with

{
    "conf1": true,
    "conf2": "2"
}

if foo.run is exported, it will be called with argument:

{
    "bar": {
     "conf1": true,
     "conf2": "2"
    }
}

before calling foo.bar

Configuration

As promised, configuration comes at last. But sometimes it's needed.

This is a minimal wowfile.js

var conf = {
    "modules": ["uglify-js",
                    "clean-css",
                    "less",
                    "sass"
   ]
}
 
module.exports.default = conf;

here is another one:

var prod = {
    "modules": ["uglify-js",
                    "clean-css",
                    "less",
                    "sass",
                    "coffee-script",
                    "typescript",
                    "html-minifier",
                    "concat"
   ],
   "less": {
    "globalVars": {"base": "https://github.com"},
    "wow": {
         "minimize": false
        }
   }
   "wow": {
       "keepIntermediate": true
   }
}
 
var test = {
    "modules": [
                "less",
                "sass",
                "coffee-script",
                "typescript",
                "html-minifier",
                "concat"
   ],
   "less": {
    "globalVars": {"base": "https://test.github.com"},
    "wow": {
         "minimize": true
        }
   }
   "wow": {
       "minimize": false
   }
}
 
module.exports.default = prod;
module.exports.test = test;

As you may have noticed, where are multiple environments, the default is called, of course default and is selected if no environment is specified.

You can select a specific environment by launching WOW with the env argument, e.g.

wow env=test

modules

This attribute contains a list of the modules that need to be loaded.

Each name will be prefixed with wow- when searching.

whitelist

Type: list of strings containing regular expressions. If this attribute is defined, only files matching these regular expression are compiled. Except if they match a regular expression in the blacklist.

blacklist

type: list of strings containing regular expressions. default: all paths containing /include/ or \include\.If this attribute is defined, files matching these regular expression are ignored when modified.

wow

This is an object containing configuration that is common to all modules, and each modules can look here to initialize its behavior accordingly. This attributes can also be passed only to some specific modules by adding the wow object to the configuration of those modules, see below.

wow.minimize

default: true. If set to false every module that does minimization of the source must NOT do it, if it's possible.

wow.keepIntermediate

default: false. if set to true every module that removes intermediate files generated by the compilation of other modules, must NOT do it. For examples this applies to uglify-js if it finds a javascript file with a source map.

Configuration of specific modules

Module configuration is specified in the dictionary, setting an object with the name of the module as key. Its contents are passed directly to the configuration of the wrapped functionality. For example for less, the object is passed to less.render. If is needed to overwrite the configuration of the wow modules, as the common configuration parameters or some other parameters specific of the module, they must be given wrapped inside an object with key wow, as passed for the less module in the example above.