SlideShare ist ein Scribd-Unternehmen logo
1 von 26
IMPROVE YOUR FRONT-END
PROJECT WORKFLOW WITH GRUNT
Den Odell
Head of Web Development, AKQA
HTML Minifier
Watch
Istanbul
Uglify
JS & CSS File Concatenation

Weitere ähnliche Inhalte

Was ist angesagt?

Core web Vitals: Web Performance and Usability
Core web Vitals: Web Performance and UsabilityCore web Vitals: Web Performance and Usability
Core web Vitals: Web Performance and UsabilityIngo Steinke
 
Evolution of GitLab Frontend
Evolution of GitLab FrontendEvolution of GitLab Frontend
Evolution of GitLab FrontendFatih Acet
 
EXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using GradleEXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using GradleEXPERTALKS
 
Cleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your LoggingCleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your LoggingMatthew Campbell, OCT
 
TallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJSTallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJSAndrew Hart
 
Google Core Web Vitals - Webinar
Google Core Web Vitals - WebinarGoogle Core Web Vitals - Webinar
Google Core Web Vitals - WebinarSpike
 
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetupWordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetuprtCamp
 
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, DistinctionWebsite Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, DistinctionKentico Software
 
Vered Flis: Because performance matters! Architecture Next 20
Vered Flis: Because performance matters! Architecture Next 20Vered Flis: Because performance matters! Architecture Next 20
Vered Flis: Because performance matters! Architecture Next 20CodeValue
 
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG WarsawAws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG WarsawServerless User Group Poland
 
Under the Hood with Headless WordPress and the Google Cloud Platform
Under the Hood with Headless WordPress and the Google Cloud PlatformUnder the Hood with Headless WordPress and the Google Cloud Platform
Under the Hood with Headless WordPress and the Google Cloud PlatformWP Engine
 
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS OfferingKubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS OfferingMauricio (Salaboy) Salatino
 
Better content presentation
Better content presentationBetter content presentation
Better content presentationgardenofwine
 
Better Content Presentation
Better Content PresentationBetter Content Presentation
Better Content Presentationgardenofwine
 
Steve Bailey — Core Web Vitals & Roadblocks to Success
Steve Bailey — Core Web Vitals & Roadblocks to SuccessSteve Bailey — Core Web Vitals & Roadblocks to Success
Steve Bailey — Core Web Vitals & Roadblocks to SuccessSemrush
 
Building Modular Dynamic Web Apps Ben Hale
Building Modular Dynamic Web Apps   Ben HaleBuilding Modular Dynamic Web Apps   Ben Hale
Building Modular Dynamic Web Apps Ben Halecatherinewall
 

Was ist angesagt? (20)

Core web Vitals: Web Performance and Usability
Core web Vitals: Web Performance and UsabilityCore web Vitals: Web Performance and Usability
Core web Vitals: Web Performance and Usability
 
Evolution of GitLab Frontend
Evolution of GitLab FrontendEvolution of GitLab Frontend
Evolution of GitLab Frontend
 
EXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using GradleEXPERTALKS: Jul 2012 - Build using Gradle
EXPERTALKS: Jul 2012 - Build using Gradle
 
Cleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your LoggingCleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your Logging
 
Building Bridges: A DevOps Story
Building Bridges:  A DevOps StoryBuilding Bridges:  A DevOps Story
Building Bridges: A DevOps Story
 
Polymer
PolymerPolymer
Polymer
 
TallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJSTallyJS #1 - Intro to AngularJS
TallyJS #1 - Intro to AngularJS
 
Google Core Web Vitals - Webinar
Google Core Web Vitals - WebinarGoogle Core Web Vitals - Webinar
Google Core Web Vitals - Webinar
 
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetupWordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
 
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, DistinctionWebsite Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
 
Vered Flis: Because performance matters! Architecture Next 20
Vered Flis: Because performance matters! Architecture Next 20Vered Flis: Because performance matters! Architecture Next 20
Vered Flis: Because performance matters! Architecture Next 20
 
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG WarsawAws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
Aws Lambda in Golang | Wojciech Barczynski | #4 Serverless UG Warsaw
 
Under the Hood with Headless WordPress and the Google Cloud Platform
Under the Hood with Headless WordPress and the Google Cloud PlatformUnder the Hood with Headless WordPress and the Google Cloud Platform
Under the Hood with Headless WordPress and the Google Cloud Platform
 
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS OfferingKubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
KubeCon NA - 2021 Tools That I Wish Existed 3 Years Ago To Build a SaaS Offering
 
Everyday React Native
Everyday React NativeEveryday React Native
Everyday React Native
 
Web vitals
Web vitalsWeb vitals
Web vitals
 
Better content presentation
Better content presentationBetter content presentation
Better content presentation
 
Better Content Presentation
Better Content PresentationBetter Content Presentation
Better Content Presentation
 
Steve Bailey — Core Web Vitals & Roadblocks to Success
Steve Bailey — Core Web Vitals & Roadblocks to SuccessSteve Bailey — Core Web Vitals & Roadblocks to Success
Steve Bailey — Core Web Vitals & Roadblocks to Success
 
Building Modular Dynamic Web Apps Ben Hale
Building Modular Dynamic Web Apps   Ben HaleBuilding Modular Dynamic Web Apps   Ben Hale
Building Modular Dynamic Web Apps Ben Hale
 

Kürzlich hochgeladen

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Kürzlich hochgeladen (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Improve Front-End Workflow with Grunt

Hinweis der Redaktion

  1. The day-to-day workflow for web developers has remained largely unchanged for a number of years as a manual process of managing assets, writing code and then testing that code in browsers. Tools have existed for checking code quality and simplifying certain tasks, but these have been run manually and, as such, tend to get forgotten.  Here at AKQA, we’ve been simplifying our workflow and improving our code quality by harnessing the power of Grunt, the JavaScript-based task runner.
  2. - Grunt’s only dependency is Node.js - Node is a platform for running JavaScript applications on a server or command line - That means that Grunt is written entirely in JavaScript.
  3. - Programs, known as ‘packages’, are installed for Node using the Node Package Manager (npm) command-line tool. - Grunt is one such package, as are its tasks.
  4. - Before we start using Grunt itself, we need to install the Grunt Command Line Interface (CLI), which provides access to the Grunt command-line tool globally across your system. - On the command prompt, install the Grunt CLI by executing this command.
  5. Let’s imagine we have a small project we’re working on which contains a HTML file, an image, a JavaScript file and a CSS file, arranged within a project folder. - We’re going to add Grunt to our workflow for this project
  6. To enable Grunt to run against the project, we need to add two files in the project root folder: a Node package file (package.json) and a Grunt configuration file (GruntFile.js). A Node package file is a text file containing JSON-formatted project properties together with a list of node package dependencies required by the project, one of which will be Grunt in our case. -Naming this file package.json and using properties defined in the npm package file specification ( https://npmjs.org/doc/ json.html) means that the associated project can be installed together with its dependencies in a similar way to other node packages.
  7. Here we assign a human-friendly title for this Node package, a machine- friendly internal name and a version number according to the Semantic Versioning format - The latter two properties are essential for any Node package so make sure you don’t leave these out here.
  8. What’s missing now are the Node package dependencies required for our project. The most important of these to us is Grunt. - The simplest way to define a dependency and download it at the same time is to execute the following on the command line in your project directory. - Here we do that for Grunt. - The --save-dev option indicates that the package file should be updated as well as the dependency being installed locally.
  9. You’ll see all the files downloading within a new node_modules folder created within your project folder.
  10. If you open the package file again, you’ll notice the following section has been added automatically to its JSON structure. - This specifies a version number for Grunt in the project package file, so you can use different versions of Grunt for different projects.
  11. Now we’ve created our package file, if you have a new developer to introduce to your project, ask them to download Node, Grunt CLI as well as the project folder onto their machine. Next, tell the new team member to navigate to the project folder on the command line and type this command.
  12. Node will then download all the dependencies automatically according to the specific version numbers listed in the package file, and placing them within a node_modules folder for the new developer. Simple as that! - A word of advice: avoid committing this folder to source code control; let each developer download the files locally to their machine using npm and the package file.
  13. All Grunt tasks are Node packages, just like Grunt itself, so we need to specify each task as a dependency in the same way to make it available to our project. Let’s assume we want to use JSHint to perform static JavaScript code analysis on our project, checking for possible errors and enforcing a consistent set of coding conventions across all the JS files in our project for all developers working on it.
  14. This is a task perfect for Grunt, and a task called grunt-contrib-jshint exists as a Node package for us to use that does just this. - As a tip, I found a simple web search for ‘Grunt JSHint’ will locate this task for you with better certainty than the package search within the npm registry itself.
  15. Installing the grunt-contrib-jshint task and adding it as a dependency to your package file is as simple as executing the following command. - The package files will download and that’s our dependencies done. - We’re ready to move on to configure the other file - GruntFile.js.
  16. - Moving onto the Grunt configuration file, GruntFile.js - Follows the same basic structure for every project. - Use this ‘wrapper’ function, which will contain all the Grunt task settings and configuration. - module.exports property denotes that this file is in the CommonJS module format adopted by Node. Don’t worry too much about that. - However, do observe the Grunt parameter passed to the function, which is an object representing the Grunt API, containing methods and properties for working with Grunt throughout the three distinct sections of code in the rest of the file: the configuration, plug-ins and the tasks.
  17. Let’s skip the configuration section for the moment and jump ahead to the plug-ins section. - This is where we register the tasks we added as dependencies in our package file earlier to make them available to run in Grunt. - Add this line to the plug-ins section, which calls the API to register the JSHint npm task by name for use with Grunt.
  18. - According to the documentation for the JSHint plug-in, it registers a task within Grunt using the internal name jshint. This is the name we will use to refer to it from within our file. - Moving ahead once again, the tasks section of the file allows several tasks to be grouped together into a single ‘custom’ task, allowing them to be run together with a single execution of Grunt. - We register a custom task named default, which calls the JSHint task using another API call. - Extra tasks can be combined with this at a later stage by adding their internal names to the array.
  19. - The configuration section represents the individual settings required to tailor each task to perform the way we want in our project. - We add the code to the configuration section of the file, which configures the JSHint task using a call to the Grunt API. - We begin the configuration by defining a property named pkg into which we’ve loaded the properties from the package.json file as a JavaScript object. - This gives us access to the project’s internal name and version number, together with its other properties without having to duplicate them across both files. - We then add the configuration for the JSHint task within a property named after that task’s internal name. - This configuration consists of a set of options, matching those of JSHint itself, allowing the specific rules for code compliance to be set in one place for use across any specified file or files in the whole project. - Here we override JSHint’s strict option, enforcing all checked functions to adhere to ECMAScript 5’s strict mode - The remaining property, all, denotes the ‘target’ of the task (the files to run JSHint against). We’re choosing to check two files for compliance when the task runs: the configuration file itself and another file whose name is generated at runtime using the code delimited by the template strings <%= and %>. -This code uses the internal project name from the package file, which we stored in the pkg property to generate the filename dynamically as my-project.js. - Many Grunt tasks are built as ‘multi-tasks’, which means they can have multiple configurations, known as targets, for use in different circumstances. This adds a lot of power, and means that you could have a different set of rules for development on your local machine compared to those used before deployment to a live production server, for example.
  20. With our configuration in place to run JSHint across two JavaScript files, let’s run Grunt to trigger the custom task we named default. At the command prompt, execute the following command in the project root folder. Grunt actually treats this particular custom task name as the default, so we can actually run the same command without specifying the task name as an option and get the same results.
  21. - Grunt runs JSHint on the configuration file and the project JavaScript file, as requested, and outputs the results as follows. - Grunt ran the JSHint task on the configuration file first and, because that file failed to meet our code compliance rules, it stopped running at that point, ignoring any other files or tasks. The exact line number and character that caused Grunt to abort is shown in the output and allows us to pinpoint the code we need to change to enable Grunt to run successfully.
  22. Edit the configuration file and add the following line at the top of the wrapper function, enforcing ECMAScript 5 strict mode.
  23. Run Grunt again and it will output the following message. -In one shot we can ensure all our JavaScript files, even in a large project, adhere to the same rules, improving quality and code maintainability. We’ve essentially set up the beginnings of a frontend code build tool that, with some further configuration and extra tasks, could refuse to let us commit our code unless it passes strict code compliance rules. This can be automated to run as part of a deployment pipeline, ensuring only code that meets your strict quality control makes it through to your live site or web app.
  24. At AKQA, we have a Base Project Setup which includes a GruntFile and a NPM package file for allowing us to start all projects with a common foundation.
  25. We’re using some of the industry’s foremost tasks to increase our code quality and improve our development experience.