Objective:
Just began to learn AngularJS, in Mu class online watching the desert teacher's video (http://www.imooc.com/learn/156), inside just began to tell the front-end development-debugging-testing tools and tool used, I also smattering the front-end development, It seems that the desert teacher after class, only to find that I used to develop the time of day by a project to drag a long time originally because I did not find a good way. In this, hope to see this blog's friends can go to see this video, especially for halfway decent's friends, played a big role.
Good gossip less said, just also to MU class online shop played ads, this section is mainly said to help group we deal with some additional tasks (compression, merger, compilation, unit testing, etc.) artifact Grunt.
It seems that the official documents I found to say are very clear, let's first go over how to build a Grunt:
- Create a new file on the desktop, named Grunt.
- Create two files in the grunt file
Package.json (will install the established repository)
Example:
{ "name": "gruntjs.cn", "version": "0.1.0", "Devdependencies": { "Grunt": "~0.4.2", "Grunt-contrib-jshint": "~0.6.3", "Grunt-contrib-nodeunit": "~ 0.2.0 ", " grunt-contrib-uglify ":" ~0.2.2 " }}
Gruntfile.js (for configuring or defining tasks, loading the grunt plugin)
Example
// wrapper function Module.exports = function (Grunt) { // Task configuration Grunt.initconfig ({Pkg:grunt.file.readJSON ( ' Package.json ' ), uglify: {build: {src: ' src/<%= pkg.name%>.js ' // Task load grunt.loadnpmtasks (' Grunt-contrib-uglify ' ); // custom task Grunt.registertask (' Default ', [' uglify '
Specific code meaning, please turn to Grunt website to browse
3, assuming you have node. js, we need the node. JS Package Manager (NPM) to download what we need, and then we open the command-line tool and go to the root directory
Run NPM install to start downloading the plugins we need
After the download is complete, we can see that our root directory grunt has one more file Node-modules
Node-modules inside is the plugin we need
Grunt-contrib-uglify is the plugin we need to compress files
Grunt-contrib-jshit Detection JS Syntax
Grunt-contrib-nodeunit the test file
Of course, we have other plug-ins, in this is not one by one repeat, the heart of the Tao friends please go to Grunt official website to see, so far, all the installation work is over, the next section began to tell how to use.
Installation of the Angularjs--grunt artifact