Recently saw an article on Javacodegeeks node, Grunt, Bower and yeoman–a modern Web dev ' s Toolkit, this article describes a Web development toolset. It's just that I've been using this toolset to develop Web applications, and I've been trying to write an article summarizing the usage of this development kit, taking this opportunity to take a look at this article and summarize my experience with this tool.In the article, the author uses the angular f
What is Grunt. js?Grunt. js is a Javascript Task Runner (Javascript Task Runner). It is based on NodeJS and can be used to automatically build, test, and generate documents.
Grunt. js is not just a build tool. In fact, it is only
Grunt JS build environment and use Getting Started 1. Application ScenariosAn automated task processing tool that automates execution of everyday requirements (code rule checking, code merging), and only retains Package.json and gruntfile.js to rely on a line of code to download.2. Build stepsGrunt relies on node. js so make sure you have node.
Using the Grunt tool to manage JS files, there are several common functions, such as compression and merging.Install the node environment first, install gruntBuild your own project in a directory environment My_projectAdd two source filesCreate a Package.json file under the project root directory{ "name": "My_project", "version": "0.1.0", "Devdependencies": { "gru
Grunt based on Node.js, with JS development, so you can use Node.js to achieve cross-platform desktop-side operations, such as file operations, and so on. In addition, grunt and its plug-ins, as a package, can be managed with NPM installation.So NPM generates a Package.json project file that records the grunt plug-ins
Recently, there is a project used requirejs to solve the front-end modularity, but with more and more pages and modules, I found that I am about to hold these lovely JS files, specifically in each page to set a bunch requirejs of configuration ( baseUrl , and so on paths ).I do not know who said, some things repeated three times, it is time to consider the automation, so I carefully pulled out of my grunt .
What you need to know:1, nodejs installation and command line use 2, Nodejs installation Application 3, Grunt preliminary understandingThis article has assumed that readers are already familiar with the above knowledge.OK, let's continue:Task 1: Merge and compress all zepto and plugins under SRC directory.--src/ ajax.js assets.js callbacks.js data.js deferred.js detect.js event.js form.js fx.js fx_methods.js gesture.js
Grunt tutorial 2
Concat plugin
Concat is a common plug-in used in grunt for file connection. For example, if you write a class library, there are three modules, such:
A. js
B. js
C. js
When your project is ready for release, you m
simple gruntfile.js:Module.exports =function(Grunt) {grunt.initconfig ({//read information from a custom JSON configuration file to make it easier to refer to it laterPkg:grunt.file.readJSON ("Example.jquery.json"), //referring to the information read above to define a copyright information header, in fact, is to use a variable concatenation of a string, after the merger compression can use this copyright informationmeta: {banner:"/*\n" + "*
ObjectiveGrunt is a front-end build tool that helps us automate the construction of front-end projects. It can be automatic to JS, CSS, HTML files, such as merging, compression and other column operations. Grunt has a lot of plugins, each plug-in implements a feature, you can use NPM name to download plug-ins, and then used them. About the use of grunt and the co
Article Introduction: Grunt to build a front-end automation workflow.
Grunt, what's this stuff?Recently very hot front-end automation gadgets, task-based command-line build tools http://gruntjs.com
What can grunt do for us?
Before you start, let's describe the following scenario:
"Scenario 1: Before the project starts"
First set up a Proja f
that Grunt.task.requires does not actually run other tasks, it simply checks to see if other tasks have been executed and has not failed.Tasks can also access configuration properties. Like what:function () { // record the property value and return NULL if the property is undefined (undefined). Grunt.log.writeln (' The Meta.name property is: ' + grunt.config (' Meta.name ')); // the same record property value, which returns null if the property is undefined (undefined). Grunt.log.writel
just want to do a grunt operation on a JS file, you do not need to create Index.js and Lib folder files, directly put the file in the root directory, and then the Gruntfile.js file in the path to change it.?Appendix 2:How to create a sample gruntfile.
Installing GRUNT-CLI
NPM install-g
. TroubleshootingView node's installation root directorynpm root -g
1
Running the grunt-version or not?Find a lot on the net, give the correct solution of not a few, so their own groping, and finally decided to add the environment variable solution.This type of problem can be solved, such as:"Gulp" is not an internal or external command, nor is it a program or batch file that can be run.5. Solution StepsMy system is windows7, my own refe
1.seaJs Direct construction of existing problemsBecause the dependencies between the modules require refer to the module name, when multiple JS modules are merged into one, the error will not be found because of the module name .2.seajs+grunt DevelopmentPlugins used:grunt-cmd-transport and grunt-cmd-concat (cmd specification)
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.