Mod is a task-based build tool for the web, it help developers quickly build robust and high-performance web applications.
- More built-in tasks
- More simplicity to use
- Configuration less(even zero), do more
- Business background, community support
- Task-based builds
- Minify everything: JS, CSS, HTML, Images
- Source linting: JS, CSS
- Modular JS for the web: AMD, CMD(will support CommonJS soon)
- CSS import file combination
- HTML conditional comments for target build
- Source stripping, automatically remove debugging code
- Common action: cat, rm, mv, mkdir, cp, hash, pack
- File watcher, trigger custom tasks when file change
- Live Browser Reloads, instantly see changes in your browser
- Image Optimization, reduce JPEG, PNG and GIF file sizes
- Project boilerplate generate
- Built-in Web Server
- Extensible, easily write plugins
- Works on most platforms: Windows, Linux, Mac OS X, Unix...
Mod is installed using NPM(Node Package Manager)
npm install -g modjs
Mod supports a powerful set of high-level commands:
__ _
____ ___ ____ ____/ / (_)_____
/ __ `__ \ / __ \ / __ / / // ___/
/ / / / / // /_/ // /_/ / / /(__ )
/_/ /_/ /_/ \____/ \__,_/__/ //____/
/___/
Usage: mod COMMAND [ARGS]
mod cat # Concatenate the content of files
mod cp # Copy one or more files to another location
mod mkdir # Create new folder
mod mv # Move or rename files or directories
mod rm # Remove files
mod strip # Source stripping
mod min # Minify js css html image files
mod lint # Validate js css files
mod build # Build an optimized version of your app, ready to deploy
mod create # Generate a project skeleton include project directory
mod init # Generate a project skeleton in target directory
mod server # Start a static web server
mod pack # Create a tarball with target directory
mod hash # Rename file with it hash value
mod search # Search the Github
- Concatenate Files
- CMD Modules Compile
- CSS Modules Compile
- JPG Image Compression
- PNG Image Compression
- JS Minify
- CSS Minify
- Source Stripping
- Inline Images DataURI
- CSS Images Sprites
Like Makefile/Rakefile, Modfile is implemented as a NodeJS module:
module.exports = {
plugins: {
sprite: "mod-sprite",
datauri: "mod-datauri"
},
tasks: {
"rm" : {
"target": "./dist"
},
"min" : {
"img": {
"source": "./img/*.png",
"dest": "./dist/img"
},
"css": {
"source": "./dist/css/*.css",
"dest": "./dist/css"
},
"html": {
"source": "*.html",
"dest": "./dist/"
},
"js": {
"source": "./dist/js/*.js",
"dest": "./dist/js"
}
},
"cat": {
"source":["./dist/js/a.js","./dist/js/b.js"],
"dest": "./dist/js/ab.js"
},
"watch" : {
"source": ["*"],
"tasks": ""
},
},
targets: {
dist: "rm min cat"
}
};
Then run 'dist' target:
mod dist
| Feature | Mod | Grunt | Yeoman |
|--------------------------+--------+------------+-----------|
| Minifier | ✓ | ✓ | ✓ |
| Linter | ✓ | ✓ | ✓ |
| HTML Conditional Comments| ✓ | ✗ | ✗ |
| CSS Combination | ✓ | ✗ | ✗ |
| Image Optimization | ✓ | ✗ | ✓ |
| Source stripper | ✓ | ✗ | ✗ |
| Modular JS | ✓ | ✗ | ✗ |
| File Watcher | ✓ | ✓ | ✓ |
| Live Browser Reloads | ✓ | ✗ | ✓ |
| Built-in WebServer | ✓ | ✓ | ✓ |
| Skeletons (Boilerplates) | ✓ | ✓ | ✓ |
| Headless browser Testing | ✗ | ✓ | ✓ |
| Extensible plugins | ✓ | ✓ | ✓ |
| Cross-platform | ✓ | ✓ | ✗ |
In addition to the built-in tasks, you can create your own tasks:
exports.summary = 'my task';
exports.usage = '<source> [options]';
exports.options = {
"d" : {
alias : 'dest'
,default : '<source>'
,describe : 'destination file'
},
"c" : {
alias : 'charset'
,default : 'utf-8'
,describe : 'file encoding type'
}
};
exports.run = function (options, callback) {
var target = options.target;
// ...
};
exports.taskName
exports.loadTask()
exports.runTask()
exports.getArgs()
exports.getConfig()
exports.getTaskConfig()
exports.log()
exports.error()
exports.warn()
exports.debug()
exports.file
exports.utils
exports._
exports.async
exports.request
exports.prompt
Mod support Windows, OS X, Linux.
Submit a new issue.
Mod is an open-source project by Tencent which builds on top of Node.js. We utilize a number of useful open-source solutions including:
- UglifyJS
- JSHint
- CleanCSS
- CSSLint
- HTMLMinifiler
- Requirejs
- Twitter Bootstrap
- HTML5 Boilerplate
Mod is released under a MIT license.