A very basic base for starting projects with Grunt
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Grunt Project

Basic project setup with Grunt to standardise and structure projects.

What's included?

  • JShint, concatenate and minify JavaScript
  • Compiles Sass with development and production options
  • Sass sourcemaps*
  • Rasterize .svg files
  • Compress .jpg/.jpeg, .png and .svg files
  • Livereload the browser on file changes

*To use sourcemaps, Sass 3.3.0 alpha must be installed: sudo gem install sass --pre

Getting Started

Make sure you have Node.js and Grunt installed:

  • Install Node.js from http://nodejs.org, or if you use Homebrew: brew install node
  • Install Grunt by running npm install -g grunt-cli
  • Install project dependancies with npm install. Make sure you're in the project root.

You may need to run the install commands as admin, so for Mac, use sudo npm install.

For more information on Grunt, see the Getting Started guide.

Directory Overview

├── css/
│   ├── sass/
│   │   └── global.scss
│   └── <package-name>.css
├── img/
│   └── src/
├── js/
│   ├── src/
│   ├── vendor/
│   ├── <package-name>.js
│   └── <package-name>.min.js
├── node_modules/
├── Gruntfile.js
├── package.json
├── index.html
└── README.md

File Structure


sass/global.scss will be compiled too css/<package-name>.css. Import all project Sass files in this file.


Any .png, .jpg, .jpeg images placed here will be compressed and SVG files will be rasterised as PNG files upon production or images task [see tasks below for more info].


JavaScript files placed in src/ will be tested with JShint, concatenated and minified to the root js/ dir. vendor/ should be used for vendor scripts, such as jQuery. Vendor scripts will not be tested with JShinted, concatenated or minified by default.


Required dependancies are installed here, do not add to version control.


This file contains all the tasks to be run. It's heavily commented so check it out.


Define project settings in this file. All dependancies are listed here too.


This file contains options for JShint.


A standard .gitignore file for ignoring files/folders from being added the repo.


Just a basic HTML file, not required for the project.


You are here!

Included Grunt Tasks


JShint, concatenate and minify JS. Compile Sass with development settings (CSS not minified).

grunt production

JShint, concatenate and minify JS. Compile Sass with production settings (CSS is minified), convert SVG to PNG, compress images.

grunt images

Convert any images in img/ from SVG to PNG. Also compress .jpg, .jpeg and .png files.

grunt watch

Watches files for changes and JShint, concatenate and minifies JS. Compiles Sass with development settings and reloads the page (requires the livereload browser plugin). Use ctrl + c to stop watching.

Useful Resources