SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
Grunt, Gulp & fabs
Build-System and Development-Workflow
for modern Web-Applications
Philipp Burgmer
Software Engineer / Consultant / Trainer
Focus: Frontend, Web Technologies
WeigleWilczek GmbH
burgmer@w11k.com
ABOUT ME
WeigleWilczek / W11k
Software Design, Development & Maintenance
Consulting, Trainings & Project Kickoff
Web Applications with AngularJS
Native Rich Clients with Eclipse RCP
ABOUT US
HOW DO YOU START A NEW WEB-APP?
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
edit, switch, refresh, test, switch, edit, switch, refresh, test, switch,
...
AND HOW DOES IT LOOK LIKE
AFTER ONE NIGHT OF
and no structure in sight
A LOT OF FILES TO MANAGE
43 Dependencies to other Libraries
169 JavaScript Files
112 HTML Templates
...
AFTER 3 MONTHS
Manage Dependencies to 3th Party Libraries
(Versioning, Conflicts, Download and Inclusion)
Include Own JavaScript and CSS Files
Structure and Modularize Code
Too Much Overhead During Development
Find Even Simple Errors Only at Runtime
PROBLEMS
SOLUTION?
THE RIGHT TOOLS MAKE ALL THE DIFFERENCE!
(http://www.nodejs.org)
Runtime for
Dev Tools
(http://www.gruntjs.com)
Task Runner
Bower
(http://www.bower.io)
Dependency
Management
Command Line Tool
Node Package
Install Binary via npm install -g bower
No Project Specific Version
BOWER
A PACKAGE MANAGER FOR THE WEB
Define Dependencies in bower.json
{
"name": "fabs-presentation",
"dependencies": {
"angular": "1.2.16",
"twbs-bootstrap-sass": "3.1.1",
"w11k-slides": "0.4.1"
}
}
Download Dependencies via bower install
Half the Problem Remains: bower Does Not Manage Inclusion
Hint: Use Fixed Versions Within a Project and Variable Within a Library
BOWER
A PACKAGE MANAGER FOR THE WEB
Command Line Tool
Lets You Automate Almost Everything
Split into 2 Node Packages
Install Binary Globally via npm install -g grunt-cli
Define Dependency to Project Specific Version in package.json
Install Locally via npm install
GRUNT
THE JAVASCRIPT TASK RUNNER
Configure Your Tasks and Targets in Gruntfile.js
Everything Is a Plugin (via NPM and package.json )
Countless Plugins Available
Tasks and Configuration Are Pure JavaScript
Register Custom Tasks in Gruntfile.js ,
No Need to Write a Plugin
GRUNT
THE JAVASCRIPT TASK RUNNER
var grunt = require('grunt');
module.exports = function () {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('dev', ['watch', 'connect:dev']);
grunt.registerTask('default', ['dev']);
grunt.initConfig({
watch: { src: { files: ['js/**/*.js', '!js/**/*.test.js'] }},
connect: { dev: { options: { port: 9000 }}}});
};
SHORTEN DEV-LIFECYCLE
WITH LIVERELOAD
var indexHtmlTask = function () {
var jsFiles = utils.filterForJS(this.filesSrc);
grunt.file.copy('src/index.html', 'build-output/index.html', {
process: function (contents) {
return grunt.template.process(contents, { data: { scripts: jsFiles }});
}
});
};
grunt.registerMultiTask('indexHtml', 'Process index.html template', indexHtmlTask);
<% scripts.forEach(function ( file ) { %>
<script type="text/javascript" src="<%= file %>"></script>
<% }); %>
indexHtml: {
dev: { files: ['js/**.*.js', '!js/**/*.test.js'] }
}
INCLUDE JAVASCRIPT FILES
WITH CUSTOM TASK
Substitute for Compiler
Syntax Check
Coding Rules Validation
Static Code Analysis
watch: {
src: {
files: ['js/**/*.js', '!js/**/*.test.js'],
tasks: ['jshint:src']
}
}
A JAVASCRIPT CODE QUALITY TOOL
Testing
SASS and/or LESS Support
Using Mock-Data During Development
Running Frontend with Real Backend
BUT WHAT ABOUT
Karma & grunt-karma for Unit/Spec Tests
Protractor & grunt-protractor for End-2-End Tests
grunt-contrib-sass & grunt-contrib-less
NPM Packages starting with grunt-*
Plugin Overview at gruntjs.com/plugins (http://gruntjs.com/plugins)
More than 2800 Plugins, but a Lot of Duplicates
NO PROBLEM
THERE ARE PLUGINS FOR EVERYTHING
Concatenation
Minification
Cache Busting
Running Tests Against Minified Code
THERE IS STILL MORE TO DO
BEFORE WE CAN DEPLOY OUR APP
Project Specific Build
Huge Gruntfile.js
Task Dependencies
Hard to Do It Right
Same Problems as with Ant
THE REAL PROBLEMS
github.com/w11k/fabs (https://github.com/w11k/fabs)
Inspired by ng-boilerplate (https://github.com/ngbp/ngbp)
Based on Our Best Practices
Configurable
Extendable via Lifecycle-Hooks
Grunt Based
FABS
FABULOUS ANGULARJS BUILD SYSTEM
Manage Frontend Dependencies with Bower
Dev-Mode with Server, Proxies and LiveReload
SASS and LESS Support
Spec and End-2-End Tests
Mocks for Tests and Dev-Mode
Project- and Developer-Configuration
Build and Serve Distribution incl. Cache Busting
FEATURES
fabs-boilerplate (https://github.com/w11k/fabs-boilerplate)
This Presentation
Real World Project
fabs (https://github.com/w11k/fabs)
DEMO
Highly Interdependent Tasks
Hard to Maintain
Hard to Extend (Even With Hooks)
Grunt Is Slow (Slower than ...)
FABS & GRUNT PROBLEMS
gulpjs.com (http://gulpjs.com)
Uses Streams Instead fo Temp Files
Runs Independent Tasks 'Parallel'
Code Over Configuration
Node Package: Install with npm install -g gulp
Plugins Are Regular Node Packages
GULP.JS
var gulp = require('gulp'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
gulp.task('process-scripts', function() {
return gulp.src('src/scripts/*.js')
.pipe(concat('1.0.1/main.js'))
.pipe(gulp.dest('dest/scripts/'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dest/scripts/'))
});
gulp.task('watch', function() {
gulp.watch('src/scripts/*.js', ['process-scripts'])
});
PROCESS JAVASCRIPT WITH GULP
A Lot of Small Tools / Plugins, Each for a Specific Task
Difficult to Keep Track of All These Tools / Plugins
No De-Facto Standard Build Tool like Maven for Java
Impossible to Write One for All Web-Apps
fabs for AngularJS Applications
Working on a Gulp Port of fabs
CONCLUSION
MEET THE SPEAKER
@ Speaker Lounge
Second Floor Directly About Reception
Philipp Burgmer
burgmer@w11k.com
www.w11k.com (http://www.w11k.com)
www.thecodecampus.de (http://www.thecodecampus.de)
Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-Applications

Mais conteúdo relacionado

Mais procurados

Testing your app with Selenium on Travis CI
Testing your app with Selenium on Travis CITesting your app with Selenium on Travis CI
Testing your app with Selenium on Travis CI
Yusuke Ando
 
'MICROFRONTENDS WITH REACT' by Liliia Karpenko
 'MICROFRONTENDS WITH REACT' by Liliia Karpenko 'MICROFRONTENDS WITH REACT' by Liliia Karpenko
'MICROFRONTENDS WITH REACT' by Liliia Karpenko
OdessaJS Conf
 
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
OdessaJS Conf
 

Mais procurados (20)

Jquery react angular
Jquery react angularJquery react angular
Jquery react angular
 
Automated Testing with Cucumber, PhantomJS and Selenium
Automated Testing with Cucumber, PhantomJS and SeleniumAutomated Testing with Cucumber, PhantomJS and Selenium
Automated Testing with Cucumber, PhantomJS and Selenium
 
Pre-render Blazor WebAssembly on static web hosting at publishing time
Pre-render Blazor WebAssembly on static web hosting at publishing timePre-render Blazor WebAssembly on static web hosting at publishing time
Pre-render Blazor WebAssembly on static web hosting at publishing time
 
Why gradle
Why gradle Why gradle
Why gradle
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & AzureBuilding Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
 
A Introduction to the World of Node, Javascript & Selenium
A Introduction to the World of Node, Javascript & SeleniumA Introduction to the World of Node, Javascript & Selenium
A Introduction to the World of Node, Javascript & Selenium
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
Testing your app with Selenium on Travis CI
Testing your app with Selenium on Travis CITesting your app with Selenium on Travis CI
Testing your app with Selenium on Travis CI
 
From devOps to front end Ops, test first
From devOps to front end Ops, test firstFrom devOps to front end Ops, test first
From devOps to front end Ops, test first
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
'MICROFRONTENDS WITH REACT' by Liliia Karpenko
 'MICROFRONTENDS WITH REACT' by Liliia Karpenko 'MICROFRONTENDS WITH REACT' by Liliia Karpenko
'MICROFRONTENDS WITH REACT' by Liliia Karpenko
 
Visual Studio: The best tool for web developers.
Visual Studio: The best tool for web developers.Visual Studio: The best tool for web developers.
Visual Studio: The best tool for web developers.
 
Use groovy & grails in your spring boot projects
Use groovy & grails in your spring boot projectsUse groovy & grails in your spring boot projects
Use groovy & grails in your spring boot projects
 
Iam New And Noteworthy
Iam New And NoteworthyIam New And Noteworthy
Iam New And Noteworthy
 
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
 
Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)
 
A Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftA Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShift
 
Single-page applications and Grails
Single-page applications and GrailsSingle-page applications and Grails
Single-page applications and Grails
 
Developing SPI applications using Grails and AngularJS
Developing SPI applications using Grails and AngularJSDeveloping SPI applications using Grails and AngularJS
Developing SPI applications using Grails and AngularJS
 

Semelhante a Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-Applications

Semelhante a Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-Applications (20)

Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 
Modern Web Application Development Workflow - web2day 2014
Modern Web Application Development Workflow - web2day 2014Modern Web Application Development Workflow - web2day 2014
Modern Web Application Development Workflow - web2day 2014
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014Modern Web Application Development Workflow - EclipseCon Europe 2014
Modern Web Application Development Workflow - EclipseCon Europe 2014
 
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...WordCamp Atlanta -  April 15 2018 - dev team workflow and processes with word...
WordCamp Atlanta - April 15 2018 - dev team workflow and processes with word...
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinar
 
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
stackconf 2020 | The path to a Serverless-native era with Kubernetes by Paolo...
 
The path to a serverless-native era with Kubernetes
The path to a serverless-native era with KubernetesThe path to a serverless-native era with Kubernetes
The path to a serverless-native era with Kubernetes
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
 
Real World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.xReal World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.x
 
Frontend Build Tools - CC FE & UX
Frontend Build Tools - CC FE & UXFrontend Build Tools - CC FE & UX
Frontend Build Tools - CC FE & UX
 
Real World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.xReal World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.x
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshop
 
Can I Contain This?
Can I Contain This?Can I Contain This?
Can I Contain This?
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Scale your Magento app with Elastic Beanstalk
Scale your Magento app with Elastic BeanstalkScale your Magento app with Elastic Beanstalk
Scale your Magento app with Elastic Beanstalk
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 

Mais de Philipp Burgmer

Mais de Philipp Burgmer (8)

Sicherheit in Single-Page-Web-Anwendungen
Sicherheit in Single-Page-Web-AnwendungenSicherheit in Single-Page-Web-Anwendungen
Sicherheit in Single-Page-Web-Anwendungen
 
EnterJS 2015 - JavaScript von Morgen schon heute
EnterJS 2015 - JavaScript von Morgen schon heuteEnterJS 2015 - JavaScript von Morgen schon heute
EnterJS 2015 - JavaScript von Morgen schon heute
 
Taugt AngularJS wirklich was? Erfahrungsbericht und Ausblick
Taugt AngularJS wirklich was? Erfahrungsbericht und AusblickTaugt AngularJS wirklich was? Erfahrungsbericht und Ausblick
Taugt AngularJS wirklich was? Erfahrungsbericht und Ausblick
 
Legacy WebApps mit AngularJS pimpen
Legacy WebApps mit AngularJS pimpenLegacy WebApps mit AngularJS pimpen
Legacy WebApps mit AngularJS pimpen
 
WJAX 2012 - Web Apps With AngularJS
WJAX 2012 - Web Apps With AngularJSWJAX 2012 - Web Apps With AngularJS
WJAX 2012 - Web Apps With AngularJS
 
JavaMagazin - AngularJS
JavaMagazin - AngularJSJavaMagazin - AngularJS
JavaMagazin - AngularJS
 
Karlsruher Entwicklertag 2013 - Webanwendungen mit AngularJS
Karlsruher Entwicklertag 2013 - Webanwendungen mit AngularJSKarlsruher Entwicklertag 2013 - Webanwendungen mit AngularJS
Karlsruher Entwicklertag 2013 - Webanwendungen mit AngularJS
 
Web Applications with AngularJS
Web Applications with AngularJSWeb Applications with AngularJS
Web Applications with AngularJS
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

Grunt, Gulp & fabs: Build Systems and Development-Workflow for Modern Web-Applications

  • 1. Grunt, Gulp & fabs Build-System and Development-Workflow for modern Web-Applications
  • 2. Philipp Burgmer Software Engineer / Consultant / Trainer Focus: Frontend, Web Technologies WeigleWilczek GmbH burgmer@w11k.com ABOUT ME
  • 3. WeigleWilczek / W11k Software Design, Development & Maintenance Consulting, Trainings & Project Kickoff Web Applications with AngularJS Native Rich Clients with Eclipse RCP ABOUT US
  • 4. HOW DO YOU START A NEW WEB-APP?
  • 5. edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, edit, switch, refresh, test, switch, ... AND HOW DOES IT LOOK LIKE AFTER ONE NIGHT OF
  • 6. and no structure in sight A LOT OF FILES TO MANAGE
  • 7. 43 Dependencies to other Libraries 169 JavaScript Files 112 HTML Templates ... AFTER 3 MONTHS
  • 8. Manage Dependencies to 3th Party Libraries (Versioning, Conflicts, Download and Inclusion) Include Own JavaScript and CSS Files Structure and Modularize Code Too Much Overhead During Development Find Even Simple Errors Only at Runtime PROBLEMS
  • 9. SOLUTION? THE RIGHT TOOLS MAKE ALL THE DIFFERENCE! (http://www.nodejs.org) Runtime for Dev Tools (http://www.gruntjs.com) Task Runner Bower (http://www.bower.io) Dependency Management
  • 10. Command Line Tool Node Package Install Binary via npm install -g bower No Project Specific Version BOWER A PACKAGE MANAGER FOR THE WEB
  • 11. Define Dependencies in bower.json { "name": "fabs-presentation", "dependencies": { "angular": "1.2.16", "twbs-bootstrap-sass": "3.1.1", "w11k-slides": "0.4.1" } } Download Dependencies via bower install Half the Problem Remains: bower Does Not Manage Inclusion Hint: Use Fixed Versions Within a Project and Variable Within a Library BOWER A PACKAGE MANAGER FOR THE WEB
  • 12. Command Line Tool Lets You Automate Almost Everything Split into 2 Node Packages Install Binary Globally via npm install -g grunt-cli Define Dependency to Project Specific Version in package.json Install Locally via npm install GRUNT THE JAVASCRIPT TASK RUNNER
  • 13. Configure Your Tasks and Targets in Gruntfile.js Everything Is a Plugin (via NPM and package.json ) Countless Plugins Available Tasks and Configuration Are Pure JavaScript Register Custom Tasks in Gruntfile.js , No Need to Write a Plugin GRUNT THE JAVASCRIPT TASK RUNNER
  • 14. var grunt = require('grunt'); module.exports = function () { grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.registerTask('dev', ['watch', 'connect:dev']); grunt.registerTask('default', ['dev']); grunt.initConfig({ watch: { src: { files: ['js/**/*.js', '!js/**/*.test.js'] }}, connect: { dev: { options: { port: 9000 }}}}); }; SHORTEN DEV-LIFECYCLE WITH LIVERELOAD
  • 15. var indexHtmlTask = function () { var jsFiles = utils.filterForJS(this.filesSrc); grunt.file.copy('src/index.html', 'build-output/index.html', { process: function (contents) { return grunt.template.process(contents, { data: { scripts: jsFiles }}); } }); }; grunt.registerMultiTask('indexHtml', 'Process index.html template', indexHtmlTask); <% scripts.forEach(function ( file ) { %> <script type="text/javascript" src="<%= file %>"></script> <% }); %> indexHtml: { dev: { files: ['js/**.*.js', '!js/**/*.test.js'] } } INCLUDE JAVASCRIPT FILES WITH CUSTOM TASK
  • 16. Substitute for Compiler Syntax Check Coding Rules Validation Static Code Analysis watch: { src: { files: ['js/**/*.js', '!js/**/*.test.js'], tasks: ['jshint:src'] } } A JAVASCRIPT CODE QUALITY TOOL
  • 17. Testing SASS and/or LESS Support Using Mock-Data During Development Running Frontend with Real Backend BUT WHAT ABOUT
  • 18. Karma & grunt-karma for Unit/Spec Tests Protractor & grunt-protractor for End-2-End Tests grunt-contrib-sass & grunt-contrib-less NPM Packages starting with grunt-* Plugin Overview at gruntjs.com/plugins (http://gruntjs.com/plugins) More than 2800 Plugins, but a Lot of Duplicates NO PROBLEM THERE ARE PLUGINS FOR EVERYTHING
  • 19. Concatenation Minification Cache Busting Running Tests Against Minified Code THERE IS STILL MORE TO DO BEFORE WE CAN DEPLOY OUR APP
  • 20. Project Specific Build Huge Gruntfile.js Task Dependencies Hard to Do It Right Same Problems as with Ant THE REAL PROBLEMS
  • 21. github.com/w11k/fabs (https://github.com/w11k/fabs) Inspired by ng-boilerplate (https://github.com/ngbp/ngbp) Based on Our Best Practices Configurable Extendable via Lifecycle-Hooks Grunt Based FABS FABULOUS ANGULARJS BUILD SYSTEM
  • 22. Manage Frontend Dependencies with Bower Dev-Mode with Server, Proxies and LiveReload SASS and LESS Support Spec and End-2-End Tests Mocks for Tests and Dev-Mode Project- and Developer-Configuration Build and Serve Distribution incl. Cache Busting FEATURES
  • 23. fabs-boilerplate (https://github.com/w11k/fabs-boilerplate) This Presentation Real World Project fabs (https://github.com/w11k/fabs) DEMO
  • 24. Highly Interdependent Tasks Hard to Maintain Hard to Extend (Even With Hooks) Grunt Is Slow (Slower than ...) FABS & GRUNT PROBLEMS
  • 25. gulpjs.com (http://gulpjs.com) Uses Streams Instead fo Temp Files Runs Independent Tasks 'Parallel' Code Over Configuration Node Package: Install with npm install -g gulp Plugins Are Regular Node Packages GULP.JS
  • 26. var gulp = require('gulp'), rename = require('gulp-rename'), concat = require('gulp-concat'), uglify = require('gulp-uglify'); gulp.task('process-scripts', function() { return gulp.src('src/scripts/*.js') .pipe(concat('1.0.1/main.js')) .pipe(gulp.dest('dest/scripts/')) .pipe(rename({suffix: '.min'})) .pipe(uglify()) .pipe(gulp.dest('dest/scripts/')) }); gulp.task('watch', function() { gulp.watch('src/scripts/*.js', ['process-scripts']) }); PROCESS JAVASCRIPT WITH GULP
  • 27. A Lot of Small Tools / Plugins, Each for a Specific Task Difficult to Keep Track of All These Tools / Plugins No De-Facto Standard Build Tool like Maven for Java Impossible to Write One for All Web-Apps fabs for AngularJS Applications Working on a Gulp Port of fabs CONCLUSION
  • 28. MEET THE SPEAKER @ Speaker Lounge Second Floor Directly About Reception