Book Image

Mastering Grunt

By : Daniel Li
Book Image

Mastering Grunt

By: Daniel Li

Overview of this book

<p>Grunt.js continues to excel as the build automation tool of choice. Along with its support for many third-party technologies, Grunt is packaged with a clean API for defining tasks. This powerful tool can streamline your workflow by automating the preparation tasks for production, such as compression, compilation, obfuscation, testing, and even pushing your web application live. This book will teach you how to master build automation and testing with Grunt. You will have the opportunity to utilize the latest and in-demand web tools, such as Git, Jade, CoffeeScript, Sass, and the Mocha testing engine, across several exciting projects by combining Grunt with them. You will also learn to create a project – a simple Bulletin Board System (BBS), which will explain the use of Grunt alongside the Mocha testing library to automate testing throughout the build process.</p> <p>Mastering Grunt will demonstrate how to leverage Grunt with other technologies to become an expert in build automation, teaching you the best practices for modern web development along the way.</p>
Table of Contents (12 chapters)

Developing a simple Bulletin Board System (BBS)


This section will investigate the development of a simple employee management system. Perform the following steps:

  1. The first thing you should do is move to your Sass file directory, located in src/styles/sass.

  2. Within this directory, you will find main.scss. Populate your main.scss file with the following imports:

    @import 'bootstrap-sass/lib/bootstrap.scss';
    @import '_bbs.scss';

    Note that when you save main.scss, the terminal running the Grunt watch task populates with an update regarding the compilation of main.css, which can be found in src/styles.

  3. Following this, open _bbs.scss and add the following lines of code:

    #board {
      .post {
        border-radius: 0;
        padding-bottom: 32px;
      }
    
      .reply {
        padding: 0 19px 0 40px;
      }
    }

    This will add the padding changes required to create an appealing bulletin board. Note that Sass's use of embedded CSS attributes allows the previous code block to be compiled to the following:

    #board .post {
      border-radius...