Using Grunt for Web automation

Source: Internet
Author: User

1. Grunt Effect

Enables repetitive work such as compression, compilation, unit testing, etc.

2, need to install the software

     

First step: Get Nodejs package from official website, double click to install (under Windows)

Step two: Open cmd command line, execute command ' node-v ', can output version number, indicating node is installed properly

Step three: On the cmd command line, enter the installation command, respectively, to install GRUNT-CLI and grunt

3, Grunt use

First step: Create Package.json and Gruntfile two files in the directory where the project is located

The contents of the Package.json can be customized as:

1     {  2  3 "name": "Project-name", 4 "version": "0.1.0", 5 "Devde Pendencies ": {  6 " grunt ":" ~0.4.5 ", 7 " Grunt-contrib-jshint ":" ~0.10.0 ", 8 "Grunt-contrib-nodeunit": "~0.4.1", 9 "grunt-contrib-uglify": "~0.5.0"  } }

Gruntfile content can be customized as follows, modified as appropriate

1Module.exports =function (grunt) {2 3 //Project configuration.4 Grunt.initconfig ({5Pkg:grunt.file.readJSON (' Package.json '),6 uglify: {7 options: {8Banner: '/*! <%= pkg.name%> <%= grunt.template.today ("Yyyy-mm-dd")%> */\n '9},Ten Build: { OneSRC: ' src/<%= pkg.name%>.js ', ADest: ' build/<%=pkg.name%>.min.js ' -       } -     } the}); -  -Load The plugin that provides the "uglify"task. -Grunt.loadnpmtasks (' grunt-contrib-uglify '); +  - //Default task (s). +Grunt.registertask (' Default ',[' uglify ']); A  at};

4, the configuration file explanation:

About Package.json:

About Gruntfile:

Using Grunt for Web automation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.