GruntJS The JavaScript Task Runner. What is Grunt? A build tool for JavaScript Uses Node to run A Gruntfile is actually just a JavaScript file Therefore,

Slides:



Advertisements
Similar presentations
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Advertisements

Sayed Ahmed Computer Engineering, BUET, Bangladesh MSc. Computer Science, U of Manitoba, Canada
The Web Warrior Guide to Web Design Technologies
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Patch Management Module 13. Module You Are Here VMware vSphere 4.1: Install, Configure, Manage – Revision A Operations vSphere Environment Introduction.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Building scalable applications with AngularJS and modern applications infrastructure Based on real life stories.
LATTICE TECHNOLOGY, INC. For Version 10.0 and later XVL Web Master Advanced Tutorial For Version 10.0 and later.
Eclipse Overview Introduction to Web Programming Kirkwood Continuing Education Fred McClurg © Copyright 2015, Fred McClurg, All Rights Reserved.
© 2010 VMware Inc. All rights reserved Patch Management Module 13.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Writing JavaDocs Mimi Opkins CECS 274 Copyright (c) Pearson All rights reserved.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Program documentation Using the Doxygen tool Program documentation1.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
1 Chapter 12: Form Builder Objects and Flexible Code.
Topic Java EE installation (Eclipse, glassfish, etc.) Eclipse configuration for EE Creating a Java Web Dynamic Project Creating your first servlet.
Programming HeuristicLab Basics A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus.
Javadoc Comments.  Java API has a documentation tool called javadoc  The javadoc tool is used on the source code embedded with javadoc-style comments.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
Videos. Adding Videos to a Web Page Videos can make our pages more interesting and engaging. Most video-hosting services, such as YouTube, will provide.
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Packaging for Voracity Solutions Control Panel David Turner.
Javadoc Dwight Deugo Nesa Matic
How does Drupal Work? Information Systems 337 Prof. Harry Plantinga.
Windows PowerShell Desired State Configuration Overview (for WMF 4.0 Preview) Windows PowerShell Desired State Configuration (DSC) is a new management.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
“RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Programming HeuristicLab Basics A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
(1) Code Walkthrough robocode-pmj-dacruzer Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of.
------TAO, MARKUS Project IT. JavaDoc ‣ JavaDoc is a standard method of commenting source code (interfaces, classes, methods, instances variables). ‣
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Maven. Introduction Using Maven (I) – Installing the Maven plugin for Eclipse – Creating a Maven Project – Building the Project Understanding the POM.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Online Conference June 17 th and 18 th Modern SharePoint Development using Visual Studio Code.
Using Ant in Eclipse Dwight Deugo Nesa Matic
Bootstrap Tutorial Overview Objective Learn how to use the bootstrap for configuring the system. Requirements Installed Version of.
Getting to Know Grunt By Writing Your Own
I18n - DateTime ASP.NET MVC. I18n DateTime – EF changes  In model classes, use attributes  DataType(DataType.DateTime)  DataType(DataType.Date)  DataType(DataType.Time)
1 Cutting Edge FE technologies for complex product August 6, 2015.
Node.js Modules Header Mastering Node.js, Part 2 Eric W. Greene
Section 4 – Link Access Module (Lam) aka Data Adapters
Node.js Express Web Applications
CARA 3.10 Major New Features
In SharePoint A Practical Guide.
Node.js Packages Header Mastering Node.js, Part 4 Eric W. Greene
Introduction to javadoc
Console Use. Console Use Exit Console Run File.
Introduction to javadoc
CS5220 Advanced Topics in Web Programming Angular – TypeScript
Presentation transcript:

GruntJS The JavaScript Task Runner

What is Grunt? A build tool for JavaScript Uses Node to run A Gruntfile is actually just a JavaScript file Therefore, you can code directly in the Gruntfile

Getting Started with Grunt Must create a package.json file Has the following attributes: name version devDependencies You can use npm init or the grunt-init package to generate one For more optional attributes see { "name": "my-project-name", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.3", "grunt-contrib-jasmine": "~0.6.1", "grunt-contrib-uglify": "~0.2.2" }

Installing Grunt In the folder with package.json, run npm install This will install grunt, its dependencies, and any packages in devDependencies locally in that folder To add plugins later use npm install --save-dev This will update package.json and install the plugin

Writing a Gruntfile A Gruntfile is a JavaScript file with the following parts A wrapper function The config object Plugin loading Custom tasks module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { options: { banner: '/*! Hello*/\n' }, build: { src: 'src/.js', dest: 'build/.min.js' } }); // Load the plugin with the "uglify" task. grunt.loadNpmTasks('grunt-contrib-uglify'); // Default task(s). grunt.registerTask('default', ['uglify']); };

Grunt Plugins All tasks are provided by plugins A plugin is a node module A list can be found at contrib plugins are “official” Some plugins you might need are contrib-concat contrib-uglify contrib-jasmine contrib-yuidoc

Grunt Plugins All tasks are provided by plugins A plugin is a node module A list can be found at contrib plugins are “official” Install a plugin: npm install --save-dev Add grunt.loadNpmTasks( ) to your Gruntfile Some plugins you might need are contrib-concat contrib-uglify contrib-jasmine contrib-yuidoc

Setting Task Options Each plugin defines a task (or tasks) Tasks are named for the action they take (jasmine, concat, etc.) Each task can have multiple targets Targets are named however you like Options can be set at the task level or target level // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { options: { banner: '/*! */\n' }, dostuff: { src: 'src/.js', dest: 'build/.min.js', options: { wrap: true } });

File Options Options that specify files have several formats: src as a property of the target destination as the key with the source files as the value on a file object An array of objects with src/dest properties Can use *, **, ?, ! and {} for pattern matching mytarget:{ src: ['a.js', 'b.js'] dest: ['c.js'] } mytarget: { files: { 'output.js': ['src/*.js'], 'test_output.js': ['test/**/*.js'] } mytarget: { files: [ {src: ['a.js', 'b.js'], dest: 'c.js'}, {src: ['ii.js'], dest: 'i.js', filter: 'isFile'} ] }

The Jasmine Task This task runs Jasmine tests on the command line Important Options: src: the JavaScript files you are testing options.specs: your Jasmine testing specs options.template: the template for your HTML jasmine: { mytarget: { src: 'src/**/*.js', options: { specs: 'tests/*Spec.js', template: 'mytemplate.tmpl' }

Creating a Template The Jasmine plugin uses underscore You have a couple options: Generate all your HTML dynamically Create a template that adds Jasmine when a flag is passed Copy and paste your HTML into a template every time you change it Jasmine Spec Runner "> ">

Using YUIDoc YUIDoc parses tags in /** special comments */ Tags /** * Class description * MyClass */ /** * Method description * methodName {String} foo Argument 1 {Object} config A config object {String} config.name The name on the config object {Function} config.callback A callback function on the config object {Boolean} [extra=false] Do extra, optional work {Boolean} Returns true on success */ /** * Property description. * propertyName {Object} "foo" */

YUIDoc is for a collection of related classes Must have at least one per source is for a function that generates an object or includes events You must have at least one per is for a function on an is for a callback The others give additional information about each of these

The YUIDoc Task The only important options are paths and outdir The rest just help the document look pretty. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), yuidoc: { mytarget: { name: ' ', description: ' ', version: ' ', url: ' ', options: { paths: 'path/to/source/code/', outdir: 'where/to/save/docs/' } });

Exercise 1.Download demo.tar from the website (or copy it from /var/www/html on the server) 2.Copy Gruntfile.js and package.json to your own project 3.Run npm install to install grunt and the necessary plugins 4.Modify the grunt file to do something with your application