Coder Social home page Coder Social logo

grunt-lab's Introduction

Grunt Lab

Grunt lab is an introductory lab for Grunt.js.

Prerequisites

Installation

$ git clone https://github.com/andersjanmyr/grunt-lab.git`
$ cd grunt-lab
$ npm install
$ bower install

Instructions

The object of this exercise is to take the following development structure.

app
├── components
│   ├── jquery
│   │   └── jquery.js
│   ├── momentjs
│   │   └── moment.js
│   └── underscore
│       └── underscore.js
├── images
│   ├── bower-logo.png
│   └── grunt-logo.svg
├── index.html
├── scripts
│   ├── main.js
│   ├── model.js
│   └── view.js
└── styles
    ├── images.css
    └── main.css

And, turn it into this optimized production structure.

dist
└── app
    ├── images
    │   ├── bower-logo.fd05710aa2cb9502dc90.png
    │   └── grunt-logo.16c32bb187681923d5a7.svg
    ├── index.html
    ├── scripts
    │   └── main.359737238b7dc0972e52.js
    └── styles
        └── main.6873d02f25d2385b9ec8.css

Detailed Instructions

  1. Open Gruntfile.js
  2. Replace CSS files with less.
  • Change file extension from .css to .less, Less is a superset of CSS.
  • Tell .gitignore to ignore css files.
  • Inside styles/main.less, @import "images.less".
  • Change index.html to only include one CSS-file main.css.
  1. Configure target less:dev using grunt-contrib-less.
  2. Add a watch target, watch:less which invokes less:dev when less files changes.
  3. Add a less:release target, which creates an optimized main.css in the dist/app/styles directory.
  4. Concatenate the Javascript files using useminPrepare, concat, and uglify.
  • Add build:js comments in index.html, <!-- build:js ...->
  1. Copy images and html files to dist with copy.
  2. Hash all assets (CSS, Javascript, and images) in dist using filerev
  3. Replace the URL:s in the HTML files and the CSS files with usemin
  • Configure usemin to replace references in index.html and main.css

Require.js

  1. Change the Javascript-files to use Require.js instead.
  2. Minify the newly created file using grunt-contrib-requirejs .

Karma

  1. Configure Karma to run the tests
  2. Configure Grunt to watch files and run tests.

grunt-lab's People

Contributors

andersjanmyr avatar

Stargazers

Vladimir Kuznetsov avatar Tom Marshall avatar  avatar

Watchers

Andreas Ronge avatar James Cloos avatar  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.