Code Monkey home page Code Monkey logo

grunt-starter's Introduction

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

ProjectRoot/
│
├── 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
├──.jshintrc
├──.gitignore
├── index.html
└── README.md

File Structure

css/

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

img/

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].

js/

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.

node_modules/

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

Gruntfile.js

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

package.json

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

.jshintrc

This file contains options for JShint.

.gitignore

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

index.html

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

README.md

You are here!

Included Grunt Tasks

grunt

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

grunt-starter's People

Contributors

markgoodyear avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.