VS2015 vnext Study Series of five: Grunt

Source: Internet
Author: User

1. Overview

Grunt: JS-based task runners. It is an application that can automatically develop some tasks.

2. Add less

Under the "Webappbowergrunt" project root directory, create a new "lesses" folder, where you add the site.less file with the code:

@bgcolor: red;body {    background-color: @bgcolor;}

3. Modify Package.json

Add: "Grunt-contrib-less": "^0.12.0", and install:

Once the installation is successful, it will appear:

4. Modify Gruntfile.js

After its code is modified:

//This is the main entry point for defining grunt tasks and using grunt plugins.//Click here to learn more.http://go.microsoft.com/fwlink/?LinkID=513275&clcid=0x409Module.exports=function (Grunt) {Grunt.initconfig ({bower: {install: {options: { TargetDir:"Wwwroot/lib", layout:"bycomponent", Cleantargetdir:false                }            }        },        //ADD This JSON object:Less : {development: {options: {paths: ["lesses"], the files: {"Wwwroot/css/site.css":"lesses/site.less" }            },        }    }); //This command registers the default task which would install Bower packages into Wwwroot/libGrunt.registertask ("default", ["Bower:install"]); //The following line loads the grunt plugins. //This line needs to is at the end of this this file.Grunt.loadnpmtasks ("Grunt-bower-task"); Grunt.loadnpmtasks ("grunt-contrib-less");};

5. Open Task Explorer

Right-click Gruntfile.js file:

Note: If the less item does not appear, click Refresh.

Result after run:

To view the generated Site.css file:

This shows the site.less compiled into SITE.CSS success!

6. Summary

About Grunt There are other features, it is very powerful, easy to use. After I study later to add it!

VS2015 vnext Study Series of five: Grunt

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.