Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Into the
parrots & boars
world
INTRODUCTION TO FRONT-END AUTOMATION
Hi! I’m Dominik
FE/UX focused web dev @ Making Waves
Engaged into projects for FIFA
A little bit of a control freak
Baking&cooking in between
1. Motivation
2. Tools required
3. Part I - The Ingredients
4. Part II - The Recipes
5. Live example
Agenda
Motivation
Tools required
Ruby, SASS, Stylus, nib, #younameit
PART I
The Ingredients
bower.js
FRONT-END PACKAGE MANAGEMENT
General information
• Download
• Manage
• Share
Setup & usage
• npm install –g bower
• bower.json
Hint: use bower init to bootstrap bower.json file
bower.json
PROJECT METADATA & DEPENDENCY MANAGEMENT
{
‘name’ : ‘project name’,
‘version’ : ‘project version’,
‘dependencies’ : {
‘package-name’ : ‘package version’
},
‘devDependencies’ : {
‘package-name’ : ‘package version’,
‘package-name’ : ‘package version’
}
}
Bower commands
• bower search <package name>
• bower install <package name>#<package version>
• bower install --save-dev <package name>#<package version>
Detailed package versioning info: https://www.npmjs.org/doc/json.html#dependencies
So… how to use bower.js?
.bowerrc
GENERAL BOWER CONFIGURATION
{
‘directory’ : ‘packages dir’,
}
Detailed bower specs: http://bit.ly/1aJGFf8
PART I
The Ingredients - yay, we got it!
PART II
The Recipes
grunt.js
FRONT-END TASK AUTOMATION
Task automation
• watching files for changes & live reload
• CSS/JS linting, minification
• CSS preprocessors compilation
• JS unit tests running
• HTML processing
• … and many many other boring tasks
Setup
• npm install –g grunt-cli
• package.json
• Gruntfile.js
What grunt-cli is?
grunt-cli
Project A
using grunt v. X
Project B
using grunt v. Y
Project setup
• package.json
• Gruntfile.js
package.json
PROJECT METADATA & GRUNT PLUGINS MANAGEMENT
{
‘name’ : ‘project name’,
‘version’ : ‘project version’,
‘devDependencies’ : {
‘package-name’ : ‘package version’
}
}
Hint: use npm init to create & preconfigure package.json
Useful commands
npm init
npm install <package>
npm install <package> --save-dev
Let’s see it in action
Gruntfile.js
GENERAL STRUCTURE
module.export = function(grunt) {
grunt.initConfig({
‘pkg’ : grunt.file.readJSON(’package.json’),
taskName : {
task configuration
}
});
grunt.loadNpmTask(’plugin-name’);
grunt.registerTask(’complexTask’, [’taskName1’,’taskName2’,…]);
}
Gruntfile.js
grunt.initConfig({
‘pkg’ : grunt.file.readJSON(’package.json’),
taskName : {
targetName : {
options: {
task options
},
src: ’files to be processed’,
dest:’output files’
}
}
});
grunt.loadNpmTask(’grunt-contrib-taskName’);
TASK DEFINITION & CONFIGURATION
Gruntfile.js
TASK EXECUTION
grunt taskName:taskTarget
Gruntfile.js
TASK CONFIGURATION – FILES MAPPING
Compact version
taskName : {
targetName : {
options: {
task options
},
src: ’input files’,
dest:’output file’
}
}
Object version
taskName : {
targetName : {
options: {
task options
},
files: {
’output file1’:[’input file1’,…],
’output file2’:[’input fileX’,…]
}
}
}
Let’s bake!
Thanks
@prokopd
dprokop @ github
blog.makingwaves.com

More Related Content

GDG Kraków - Intro to front-end automation using bower.js & grunt.js