the value of a global object or the value of a project configuration when registering a task.In the following example, running grunt Set_global:name:peter set_config:target:staging deploy at the command line results in a global.name value of "Peter" and Grunt.config (' target ') will return "staging". Therefore, the deploy task can use these values.function= val;}); Grunt.registertask (function(name, Val) {grunt.config.set (name, Val);});Why do I get
Front-end automated Grunt tutorial and automated Grunt tutorial
After learning about Bootstrap recently, I found that Bootstrap uses LESS. Well, I started to learn LESS and LESS about it. I found that the automatic compilation tool Grunt and the
knowledge. But--if you don't finish this article, I have one last big trick. But you may have to pay for a meal + a pack of cigarettes--check out my recorded video tutorial, "Building an automated web front-end development environment with Grunt" (the tutorial has a source download) to make sure you'll use it when you're finished.(PS: It happens that this articl
knowledge. But--if you don't finish this article, I have one last big trick. But you may have to pay for a meal + a pack of cigarettes--check out my recorded video tutorial, "Building an automated web front-end development environment with Grunt" (the tutorial has a source download) to make sure you'll use it when you're finished. (PS: It happens that this arti
knowledge. But--if you don't finish this article, I have one last big trick. But you may have to pay for a meal + a pack of cigarettes--check out my recorded video tutorial, "Building an automated web front-end development environment with Grunt" (the tutorial has a source download) to make sure you'll use it when you're finished.(PS: It happens that this articl
knowledge. But--if you don't finish this article, I have one last big trick. But you may have to pay for a meal + a pack of cigarettes--check out my recorded video tutorial, "Building an automated web front-end development environment with Grunt" (the tutorial has a source download) to make sure you'll use it when you're finished.(PS: It happens that this articl
required plugins locally, and this time the grunt project will have many more files.4,gruntfile.jsAll the basic implementations are in the file, so it's the most important.in here};This is a container, and all content methods must be written inside.Initializationgrunt.initconfig ({ Pkg:grunt.file.readJSON (' Package.json '), uglify: { options: { ‘/*! }, build: { ' src/ , ' build/ );PKG load Package.json, read the contents
(Livereload) "Video demo stamp Here"Command line execution:
After the encoding is complete, build "video demo stamp Here"Command line execution:
Grunt Usage Summary
Simple configuration, configuration file Gruntfile.js is the JS format, closer to the front-end knowledge points. Relative to Ant and the like based on Java, but also the XML configuration, relatively low learning costs.
Gr
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
method Loading the task from the grunt plugin, the project template loads the Grunt-bower-task by default. The following adds agrunt-contrib-less。 在解决方案视图,选择gruntfile.js 右键Task Runner Explorer By selecting the task name "less", click Run: The Output window runs as follows: Open the/wwwroot/css/site.css file to see the following compiled CSS file: -color: #008080 Running the program, the background col
/* abcde */, foo/*.js bar/*.js baz/*.js generate a build/abcde.js file named by using all of the files in banner, along with + +.Import External DataGrunt has a Grunt.file.readJSON and Grunt.file.readYAML two methods for introducing JSON and YAML data.As an example:grunt.initconfig ({ Pkg:grunt.file.readJSON (' Package.json '), uglify: { options: { ‘/*! }, dist: { ' src/, ' dist/ );In the above gruntfile, the metadata for the project is imported from the Package.jso
During the development of JavaScript, you often encounter repetitive tasks such as merging files, compressing code, checking syntax errors, converting SASS code into CSS code, and so on. Usually, we need to use different tools to accomplish different tasks, both repetitive labor and time-consuming. Grunt is a tool invented to solve this problem and can help us automate the management and operation of various tasks.
Simply put,
rely on the module to proactively update to the Package.json file):watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvymlsbgzlbgxlcg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">4. Run the grunt build task under the current Test folder to achieve version number build task:5. This version number task build is complete. Be able to notice that the corresponding compressed file is generated under the Dest folder:This simple
Here is a record of grunt plug-in development of some key points, as notes, more concise, more suitable for grunt some understanding of the students. Note: The demo in this article may have some small differences in Linux or OS X in the Windows operating system.
I. Environmental preparedness
1. Install Node.js
Select the appropriate version of the Node.js website to download and install. After the installat
I am now using node.js in several small projects. There are some very powerful tools in the node system. One of my favorite examples is grunt.
Grunt is a tool that allows you to define tasks and then run them by command, running on the command line:
The code is as follows
Copy Code
Grunt Watch
This will start a watch task t
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 may need to combine these three modules into a large module, all. js. This can reduce HTTP requests and increase the page response speed
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 that are used in the current project, and
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
Based on Visual Studio 2015, you can: easily manage front-end packages such as jquery, Bootstrap, or angular. Automate tasks such as less, JavaScript compression, jslint, JavaScript unit tests, and more. Easy access to the Web Developer Ecosystem Toolkit.
To implement these scenarios, Visual Studio 2015 has built in a number of popular Third-party toolkits: Bower:web Package Manager, Bower can help you install front-end packages, including JavaScript, CSS class libraries. For server-side package
imweb_templatedrwxr-xr-x 10 Root staff 340 5 10 jsdrwxr-XR-x 5 root staff 170 5 9 libsdrwxr-XR-x 10 casperchen staff 340 5 10 node_modules-rw-r -- r -- 1 root staff 458 5 10 package. jsondrwxr-XR-x 4 root staff 136 5 9 srcdrwxr-XR-x 5 root staff 170 5 9 Test V. Comparison of grunt, ant, and mod
Grunt is introduced at the beginning, and ant and AVEN are briefly described below.
Ant: Kids shoes that
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.