front-end-developer-tools

Front-end Developer Tools

Nowadays front-end development isn’t just about JavaScript ,html and css there are a lot of other new entrants that will help you to automate your process and save precious development time.
The first technology that you will encounter is grunt.

GRUNT

Grunt is JavaScript task-runner designed to automate almost everything.Its thousand of plugins has you covered for normal tasks like minification , concatenation and linting as well as image compression , building sass , coffeescript or your favorite pre-processor , unit testing , end-to-end testing etc.

It works by defining your development requirements in package.json.
Example


{
"name": "my-project-name",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2"
}
}

Then you define your Gruntfile.js which will contain the individual tasks as well as group tasks which says which files to minify and where to paste them.

A sample gruntfile


module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'qunit']
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('test', ['jshint', 'qunit']);

grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);

};

After that you just run npm install and you have a simple workflow ready.

Grunt Official

BOWER

Bower is the package manager for the front end web development similar to what npm is to node-js.
You have a bower.json

Example bower.json file


{
"name": "my-project",
"version": "1.0.0",
"main": "path/to/main.css",
"ignore": [
".jshintrc",
"**/*.txt"
],
"dependencies": {
"": "",
"": "",
"": " "
},
"devDependencies": {
"": ""
}
}

Bower Official

CoffeeScript

CoffeeScript is a little language for Ruby affectionados that compiles to javascript.Its for you if you don’t like brackets in your code.

This is how you express a one-line function in javascript :-


var square = function(x) {
return x * x;
};

A better more concise version will be in coffeescript :


square = (x) -> x * x

Similarly for Array comprehensions you have :


cubes = (math.cube num for num in list)

instead of the long way in javascript


cubes = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = list.length; _i < _len; _i++) { num = list[_i]; _results.push(math.cube(num)); } return _results; })();

Coffescript Official

SASS / LESS

Less and Sass are CSS pre-processors, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable.

Less and Sass can run inside Node, in the browser and inside Rhino. There are also many 3rd party tools that allow you to compile your files and watch for changes.

You should be using css pre-processors for large projects .To explain ,Bootstrap uses a central base.less file which contains all the color names , default table spacing , all you need to do is to change that file and it will be propagated throughout.

Yet the best features are mixins or functions which enable you to use lighten , darken , saturate , math functions finally.

Example , here is the LESS code

@base: #f938ab;

.box-shadow(@style, @c) when (iscolor(@c)) {
-webkit-box-shadow: @style @c;
box-shadow: @style @c;
}
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
.box-shadow(@style, rgba(0, 0, 0, @alpha));
}
.box {
color: saturate(@base, 5%);
border-color: lighten(@base, 30%);
div { .box-shadow(0 0 5px, 30%) }
}

and this is the compiled css code :

.box {
color: #fe33ac;
border-color: #fdcdea;
}
.box div {
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

LESS Official
SASS Official

YEOMEN

Yeomen should be the default scaffolding tool for your next web project.

How to use in three steps :-

npm install -g yo
npm install -g generator-angular-fullstack
yo angular-fullstack myapp

The above commands will install the angular-full-stack generator :
[Note you will need MongoDB installed for this stack]
Yeomen will also install grunt , bower and other goodies directly into your workflow.

These are the list of all the generators available : http://yeoman.io/community-generators.html

Yeoman Official

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>