Use the Node. js-based build tool Grunt to publish ASP. NETMVC project_node. js

Source: Internet
Author: User
Tags install node
This article mainly introduces the use of Node-based. js build tool Grunt to release ASP. the NETMVC project tutorial and automated build tool Grunt has compilation, compression, unit testing, and other functions. It is very powerful. If you need it, refer to the following. Grunt Introduction
Grunt is a construction tool based on js and node. js. Due to the popularity of node. js during this time, grunt has a wide range of open-source community support and has produced many plug-ins. Some plug-ins are scattered in the node community. Building is a broad expression. The traditional understanding is to compile, package, and copy. Nowadays, with more and more technologies, building also includes preprocessing of front-end components, for example, sass and less are preprocessed into css, css, and js compression and merging. Grunt plug-ins can well support these new building concepts, and are more suitable for projects built with open source technology. Although Grunt is more used for program construction, Grunt is essentially a task running tool used to solve repetitive work.

Grunt entry
Install
Download and install Node. js.

Check the installation and version:

node -v

v0.10.25

Install the grunt command line tool grunt-cli and use-g for global installation. This can be used in any directory. The following command adds grunt to your system search path, so you can use this command in any directory.

npm install -g grunt-cli

Note that in linux or mac, an error with no permissions is reported. In this case, you must add a sudo

sudo npm install grunt-cli -g

View version:

grunt –version

grunt-cli v0.1.13

Uninstall. If you have installed a global Grunt before, delete it first.

npm uninstall -g grunt

Grunt-cli is just a grunt command line interface. grunt and its plug-ins must be used. The grunt module must be installed under the project path (usually under the project root directory), that is, the plug-in module is required. When the grunt command is executed, it will use the require command of nodejs to find the installed grunt locally. Because of this, you can run the grunt command in any subdirectory. If cli finds a locally installed grunt, it loads the grunt library, applies the configuration you wrote in GruntFile, and then executes the corresponding task.

Configuration File
Package. json
Package. json is used to save the node modules installed in the current directory, for example:

{ "name": "my-project-name", "version": "0.1.0", "author": "Your Name", "devDependencies": { "grunt": "~0.4.1" }}

You can manually create this file, or use the npm init command and follow the prompts to create the package. json file. If you have manually created package. json, you only need to use npm install to download and install the required modules. When the module is installed, it is saved in the node_modules directory.

To add the required modules later, run the following command to synchronously update the package. json file.

npm install 
 
   --save-dev
 

Gruntfile. js
Like Makefile, this file is a file that guides grunt on tasks. You need to configure the parameters required by each plug-in module, load the plug-in, and define the task.

Related Article

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.