Grunt+requirejs+angularjs Simple Application

Source: Internet
Author: User

Two URLs

Http://www.gruntjs.org/docs/getting-started.html

Http://gruntjs.com/plugins

Steps:

1.CD Demo Folder

2. Installing GRUNT-CLI

NPM install-g GRUNT-CLI//Global Install-G

3. Manual production or automatic production Package.json

Automatic NPM init//After entering name and version on Demand ...

4 Creating Gruntfile.js

Touch Gruntfile.js

5. Install plugin plug-in usage see Http://gruntjs.com/plugins

NPM Install grunt--save-dev

NPM Install grunt-contrib-uglify--save-dev

NPM Install Grunt-contrib-watch--save-dev

NPM Install Grunt-contrib-requirejs--save-dev

6. Running

Grunt

The Gruntfile is configured as follows

Module.exports =function(grunt) {//project ConfigurationGrunt.initconfig ({Pkg:grunt.file.readJSON (' Package.json '), uglify: {options: {banner:‘/*! <%= pkg.name%> <%= grunt.template.today ("Yyyy-mm-dd")%> */\n '}, Index: {src: [' Scripts/app/indexapp.js ', ' scripts/controllers/indexctrl.js '],//the source file to compressDest: ' scripts/<%= pkg.name%>.min.js '//post-compressed output position}}, watch: {scripts: {files: [' Scripts/**/*.js '], tasks: [' Requirejs '], Options: {spawn:false}}}, Requirejs: {compile: {options: { BASEURL:".", paths: {requirelib:' Scripts/requiremain/require '}, include:' Requirelib ',//If you need to press the require in (so that the entire project only needs a JS file), set its path, andName: ' Scripts/requiremain/indexmain ', out:' Scripts/requiremain/index.js ',//the file name of the output                    //optimize: ' None ',//comment out this line can simultaneously compress the merged JS fileMainconfigfile: ' Scripts/requiremain/indexmain.js '//handle module dependencies with a written main.js file                }            }        }    }); //Load plug-ins that provide "uglify" tasksGrunt.loadnpmtasks (' grunt-contrib-uglify '); Grunt.loadnpmtasks (' Grunt-contrib-watch '); Grunt.loadnpmtasks (' Grunt-contrib-requirejs '); //Default task uses Uglify    //grunt.registertask (' Default ', [' uglify ']);    //Default task uses RequirejsGrunt.registertask (' Default ', [' Requirejs ', ' watch ']);};

Demo download please go to angularjs Chinese community 278252889 or Angularjs Chinese Community 2 Group File download

Grunt+requirejs+angularjs Simple Application

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.