1,http://nodejs.org/download/installation Nodejs
2. Configure the environment variable to place the installation directory of the Nodejs in the PATH environment variable
3, in cmd in NPM install-g grunt-cli, if already installed, NPM uninstall-g Grunt This sentence can be deleted
4,grunt-version to see if the installation was successful
5, create Package.json in the directory you want to compress
6, a simple sample of Package.json
{
"name": "Umeditor",
"title": "Umeditor",
"description": "Umeditor",
"version": "1.2.2",
" Homepage ":" Https://github.com/fex-team/umeditor ",
" author ": {
" name ":" F-cube @ fex ",
" url ":"/HTTP/ Fex.baidu.com "
},
" repository ": {
" type ":" Git ",
" url ":" Https://github.com/fex-team/umeditor.git "
},
"keywords": [
"Umeditor",
"Web Editor",
"Ueditor",
"JavaScript"
],
"bugs": {
"url" : "Https://github.com/fex-team/umeditor/issues"
},
"dependencies": {
"grunt": "~0.4.1",
" Grunt-contrib-concat ":" ~0.3.0 ",
" grunt-contrib-cssmin ":" ~0.6.0 ",
" Grunt-closurecompiler ":" ~0.9.9 ",
" Grunt-contrib-copy ":" ~0.4.0 ",
" grunt-transcoding ":" ~0.1.1 ",
" Grunt-text-replace ":" ~0.3.9 ",
" Grunt-contrib-compress ":" ~0.7.0 "
},
" Devdependencies ": {
" grunt ":" ~0.4.1 ",
" Grunt-contrib-concat ":" ^0.3.0 ",
" grunt-contrib-uglify ":" ^0.5.1 "
}
}
7, create Gruntfile.js
A simple example
Module.exports = function (grunt) {
Grunt.initconfig ({
Our Jshint options
Our concat options
Concat: {
Options: {
},
Dist: {
SRC: [' src/*.js '],//grunt mini match for your scripts to concatenate
Dest: ' dest/edit.js '//where to output the script
}
},
Our uglify options
Uglify: {
JS: {
Files: {
' Dest/edit.js ': [' dest/edit.js ']//save over the newly created script
}
}
}
});
Load our Tasks
Grunt.loadnpmtasks (' Grunt-contrib-jshint ');
Grunt.loadnpmtasks (' Grunt-contrib-concat ');
Grunt.loadnpmtasks (' grunt-contrib-uglify ');
Default Tasks to run
Grunt.registertask (' Default ', [' concat ', ' uglify ']);
Grunt.registertask (' development ', [' jshint ']);
Grunt.registertask (' Production ', [' jshint ', ' concat ', ' uglify ']);
}
7, perform NPM install grunt--save-dev to keep the latest grunt in your directory
8, the implementation of the Grunt command on the implementation of packaging