SlideShare a Scribd company logo
1 of 50
Download to read offline
Forget Grunt & Gulp
Webpack & NPM tasks rule them all!
Who?
• Derek Stavis
Who?
• Derek Stavis
• Coding stuff since 2000
Who?
• Derek Stavis
• Coding stuff since 2000
• High level stuff
Who?
• Derek Stavis
• Coding stuff since 2000
• High level stuff
• Low level stuff
Who?
• Derek Stavis
• Coding stuff since 2000
• High level stuff
• Low level stuff
• Design stuff
Who?
• Derek Stavis
• Coding stuff since 2000
• High level stuff
• Low level stuff
• Design stuff
• github.com/derekstavis
Who?
• Derek Stavis
• Coding stuff since 2000
• High level stuff
• Low level stuff
• Design stuff
• github.com/derekstavis
• github.com/oh-my-fish
But before you ask
Gulp Configura:on File
var app, base, concat, directory, gulp,
hostname, path, refresh, sass, uglify, del,
connect, autoprefixer, babel;
var autoPrefixBrowserList = ['last 2
version', 'safari 5', 'ie 8', 'ie 9', 'opera
12.1', 'ios 6', 'android 4'];
gulp = require('gulp');
gutil = require('gulp-util');
concat = require('gulp-concat');
uglify = require('gulp-uglify');
sass = require('gulp-sass');
connect = require('gulp-connect');
del = require('del');
autoprefixer = require('gulp-autoprefixer');
babel = require('gulp-babel');
gulp.task('connect', function() {
connect.server({
root: 'app',
livereload: true
});
});
gulp.task('images-deploy', function() {
gulp.src(['app/images/**/*'])
.pipe(gulp.dest('dist/images'));
});
gulp.task('scripts', function() {
//this is where our dev JS scripts are
return gulp.src('app/scripts/src/**/*.js')
.pipe(babel({ presets: ['es2015',
'react'] })
.pipe(concat('app.js'))
.on('error', gutil.log)
.pipe(uglify())
.pipe(gulp.dest('app/scripts'))
.pipe(connect.reload());
});
gulp.task('scripts-deploy', function() {
return gulp.src('app/scripts/src/**/
*.js')
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/scripts'));
});
gulp.task('styles', function() {
return gulp.src('app/styles/scss/
init.scss')
.pipe(sass({
errLogToConsole: true,
includePaths: [
'app/styles/scss/'
]
}))
.pipe(autoprefixer({
browsers: autoPrefixBrowserList,
cascade: true
}))
.on('error', gutil.log)
.pipe(concat('styles.css'))
.pipe(gulp.dest('app/styles'))
.pipe(connect.reload());
});
gulp.task('styles-deploy', function() {
return gulp.src('app/styles/scss/
init.scss')
.pipe(sass({
includePaths: [
'app/styles/scss',
]
}))
.pipe(autoprefixer({
browsers: autoPrefixBrowserList,
cascade: true
}))
.pipe(concat('styles.css'))
.pipe(gulp.dest('dist/styles'));
});
gulp.task('html', function() {
return gulp.src('app/*.html')
.pipe(connect.reload())
.on('error', gutil.log);
});
gulp.task('html-deploy', function() {
gulp.src('app/*')
.pipe(gulp.dest('dist'));
gulp.src('app/.*')
.pipe(gulp.dest('dist'));
gulp.src('app/fonts/**/*')
.pipe(gulp.dest('dist/fonts'));
gulp.src(['app/styles/*.css', '!app/styles/
styles.css'])
.pipe(gulp.dest('dist/styles'));
});
gulp.task('clean', function() {
del('dist');
});
//this is our master task when you run `gulp`
in CLI / Terminal
//this is the main watcher to use when in
active development
// this will:
// startup the web server,
// start up livereload
// compress all scripts and SCSS files
gulp.task('default', ['connect', 'scripts',
'styles'], function() {
gulp.watch('app/scripts/src/**',
['scripts']);
gulp.watch('app/styles/scss/**',
['styles']);
gulp.watch('app/*.html', ['html']);
});
gulp.task('deploy', ['clean'], function () {
gulp.start('scripts-deploy', 'styles-
deploy', 'html-deploy', 'images-deploy');
});
PROBLEM?
The Proposal:
Concern Separa:on
Build Pipeline → Webpack

Task Management → NPM
So…?
Webpack
Webpack
What is Webpack?
What is Webpack?
• Module bundler
What is Webpack?
• Module bundler
• Supercharges require
What is Webpack?
• Module bundler
• Supercharges require
• Anything is require-able
What is Webpack?
• Module bundler
• Supercharges require
• Anything is require-able
• TransformaNons are based on loaders
What is Webpack?
• Module bundler
• Supercharges require
• Anything is require-able
• TransformaNons are based on loaders
• Other tasks can be implemented as plugins
What is Webpack?
• Module bundler
• Supercharges require
• Anything is require-able
• TransformaNons are based on loaders
• Other tasks can be implemented as plugins
• Outputs assets in single or mulNple files
What is Webpack?
• Module bundler
• Supercharges require
• Anything is require-able
• TransformaNons are based on loaders
• Other tasks can be implemented as plugins
• Outputs assets in single or mulNple files
• Built-in hashing → Easy cache invalidaNons
Webpack Features
How does Webpack?
J S X
How does Webpack?
J S X J S ( E S 5 )
babel-loader
How does Webpack?
J S X J S ( E S 5 )
babel-loader
S C S S
How does Webpack?
J S X J S ( E S 5 )
babel-loader
S C S S C S S
postcss-loader
How does Webpack?
J S X J S ( E S 5 )
babel-loader
S C S S C S S
postcss-loader
P N G
How does Webpack?
J S X J S ( E S 5 )
babel-loader
S C S S C S S
postcss-loader
P N G B A S E 6 4
file-loader
How does Webpack?
J S X J S ( E S 5 )
babel-loader
S C S S C S S
postcss-loader
P N G B A S E 6 4
file-loader
B U N D L E . J S
How does Webpack?
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
module.exports = {
entry: "./index.js",
output: {
path: path.join(__dirname, 'dist'),
filename: "bundle.js"
},
module: {
loaders: [
{
test: /.css$/,
loader: "style!css"
},
{
test: /.js$/,
loader: "babel"
},
{
test: /.(svg|ttf|otf|eot|woff|woff2|png|jpg|gif)$/,
loader: "file"
}
]
},
plugins: [
new CopyPlugin([
{ from: 'index.html' }
]),
new Uglify([
{ from: 'index.html' }
])
]
}
Webpack Configura:on File
webpack.github.io/docs/tutorials/geOng-started
Ok, but how we do tasks?
Use NPM scripts
What are NPM scripts
What are NPM scripts
• Custom commands through run-script
What are NPM scripts
• Custom commands through run-script
• Pre-hooks for custom commands
What are NPM scripts
• Custom commands through run-script
• Pre-hooks for custom commands
• Include package binary entry points
What are NPM scripts
• Custom commands through run-script
• Pre-hooks for custom commands
• Include package binary entry points
• Command composiNon
What are NPM scripts
npm install -g
npm run-script
npm run
IT’S DEMO TIME
BYE GRUNT AND GULP
hXp://:ny.cc/kill-gg
Thanks!
Ques:ons?
@derekstavis
github.com/derekstavis
linkedin.com/in/derekstavis
derekstavis@me.com

More Related Content

What's hot

Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
Amit Thakkar
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
Ngoc Dao
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 

What's hot (20)

Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.Orchestration? You Don't Need Orchestration. What You Want is Choreography.
Orchestration? You Don't Need Orchestration. What You Want is Choreography.
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
SockJS Intro
SockJS IntroSockJS Intro
SockJS Intro
 
Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)Improving WordPress performance (xdebug and profiling)
Improving WordPress performance (xdebug and profiling)
 
TDC2016SP - Esqueça Grunt ou Gulp. Webpack and NPM rule them all!
TDC2016SP -  Esqueça Grunt ou Gulp. Webpack and NPM rule them all!TDC2016SP -  Esqueça Grunt ou Gulp. Webpack and NPM rule them all!
TDC2016SP - Esqueça Grunt ou Gulp. Webpack and NPM rule them all!
 
Learn jobDSL for Jenkins
Learn jobDSL for JenkinsLearn jobDSL for Jenkins
Learn jobDSL for Jenkins
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 
Automatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress pluginsAutomatic testing and quality assurance for WordPress plugins
Automatic testing and quality assurance for WordPress plugins
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Infrastructure = Code
Infrastructure = CodeInfrastructure = Code
Infrastructure = Code
 
hacking with node.JS
hacking with node.JShacking with node.JS
hacking with node.JS
 
GlassFish Embedded API
GlassFish Embedded APIGlassFish Embedded API
GlassFish Embedded API
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web Applications
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorld
 

Viewers also liked

Preswentación teria de colas
Preswentación teria de colasPreswentación teria de colas
Preswentación teria de colas
Cris Tina
 
Triatlon Villa de Gijon-Playa de Poniente 2014
Triatlon Villa de Gijon-Playa de Poniente 2014Triatlon Villa de Gijon-Playa de Poniente 2014
Triatlon Villa de Gijon-Playa de Poniente 2014
Cruz Portilla
 
Siegfried Brochure
Siegfried BrochureSiegfried Brochure
Siegfried Brochure
slccbrown
 
FORCAM White Paper (2016) - Lead by TRUE OEE
FORCAM White Paper (2016) - Lead by TRUE OEEFORCAM White Paper (2016) - Lead by TRUE OEE
FORCAM White Paper (2016) - Lead by TRUE OEE
Mohamed Abuali
 

Viewers also liked (20)

Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)Get Grulping with JavaScript Task Runners (Matt Gifford)
Get Grulping with JavaScript Task Runners (Matt Gifford)
 
JavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & GruntJavaScript Task Runners - Gulp & Grunt
JavaScript Task Runners - Gulp & Grunt
 
Multiplatform hybrid development
Multiplatform hybrid developmentMultiplatform hybrid development
Multiplatform hybrid development
 
La domótica
La domóticaLa domótica
La domótica
 
Gazeta
GazetaGazeta
Gazeta
 
Preswentación teria de colas
Preswentación teria de colasPreswentación teria de colas
Preswentación teria de colas
 
Triatlon Villa de Gijon-Playa de Poniente 2014
Triatlon Villa de Gijon-Playa de Poniente 2014Triatlon Villa de Gijon-Playa de Poniente 2014
Triatlon Villa de Gijon-Playa de Poniente 2014
 
Sergio de Otto - Fundación Renovables
Sergio de Otto - Fundación RenovablesSergio de Otto - Fundación Renovables
Sergio de Otto - Fundación Renovables
 
Presentacion Nexus Talleres
Presentacion Nexus TalleresPresentacion Nexus Talleres
Presentacion Nexus Talleres
 
Lia Nr. 136
Lia Nr. 136Lia Nr. 136
Lia Nr. 136
 
Tips de belleza pps
Tips de belleza ppsTips de belleza pps
Tips de belleza pps
 
Leseprobe Buch: „Ernesto der Seebär“ bei Pax et Bonum Verlag Berlin
Leseprobe Buch: „Ernesto der Seebär“ bei Pax et Bonum Verlag BerlinLeseprobe Buch: „Ernesto der Seebär“ bei Pax et Bonum Verlag Berlin
Leseprobe Buch: „Ernesto der Seebär“ bei Pax et Bonum Verlag Berlin
 
Portafolio2010
Portafolio2010Portafolio2010
Portafolio2010
 
Cronograma XII Jornadas Nacionales de Antropología Biológica
Cronograma XII Jornadas Nacionales de Antropología BiológicaCronograma XII Jornadas Nacionales de Antropología Biológica
Cronograma XII Jornadas Nacionales de Antropología Biológica
 
Siegfried Brochure
Siegfried BrochureSiegfried Brochure
Siegfried Brochure
 
FORCAM White Paper (2016) - Lead by TRUE OEE
FORCAM White Paper (2016) - Lead by TRUE OEEFORCAM White Paper (2016) - Lead by TRUE OEE
FORCAM White Paper (2016) - Lead by TRUE OEE
 
Design de Produto
Design de ProdutoDesign de Produto
Design de Produto
 
Dangers of Bad Breath
Dangers of Bad BreathDangers of Bad Breath
Dangers of Bad Breath
 
Low Impact Development - Call to Action
Low Impact Development - Call to ActionLow Impact Development - Call to Action
Low Impact Development - Call to Action
 
Dealing with people's negative perception at work
Dealing with people's negative perception at workDealing with people's negative perception at work
Dealing with people's negative perception at work
 

Similar to Forget Grunt and Gulp! Webpack and NPM rule them all!

9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux
chinkshady
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
Almir Mendes
 
Quest for the Perfect Workflow for McrFRED
Quest for the Perfect Workflow for McrFREDQuest for the Perfect Workflow for McrFRED
Quest for the Perfect Workflow for McrFRED
Andi Smith
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
tomcopeland
 
Deploy made easy (even on Friday)
Deploy made easy (even on Friday)Deploy made easy (even on Friday)
Deploy made easy (even on Friday)
Riccardo Bini
 

Similar to Forget Grunt and Gulp! Webpack and NPM rule them all! (20)

From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Webpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
 
(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
 
9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux
 
Netflix Nebula - Gradle Summit 2014
Netflix Nebula - Gradle Summit 2014Netflix Nebula - Gradle Summit 2014
Netflix Nebula - Gradle Summit 2014
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!Gradle: The Build System you have been waiting for!
Gradle: The Build System you have been waiting for!
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
Sprockets
SprocketsSprockets
Sprockets
 
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style GuidesAdvanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
 
Quest for the Perfect Workflow for McrFRED
Quest for the Perfect Workflow for McrFREDQuest for the Perfect Workflow for McrFRED
Quest for the Perfect Workflow for McrFRED
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting for
 
Gradle
GradleGradle
Gradle
 
Migrating Legacy Data (Ruby Midwest)
Migrating Legacy Data (Ruby Midwest)Migrating Legacy Data (Ruby Midwest)
Migrating Legacy Data (Ruby Midwest)
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Deploy made easy (even on Friday)
Deploy made easy (even on Friday)Deploy made easy (even on Friday)
Deploy made easy (even on Friday)
 

More from Derek Willian Stavis

More from Derek Willian Stavis (7)

React performance
React performanceReact performance
React performance
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Packing it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to nowPacking it all: JavaScript module bundling from 2000 to now
Packing it all: JavaScript module bundling from 2000 to now
 
Ramda, a functional JavaScript library
Ramda, a functional JavaScript libraryRamda, a functional JavaScript library
Ramda, a functional JavaScript library
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
Introdução ao MongoDB em 30 slides
Introdução ao MongoDB em 30 slidesIntrodução ao MongoDB em 30 slides
Introdução ao MongoDB em 30 slides
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Forget Grunt and Gulp! Webpack and NPM rule them all!

  • 1. Forget Grunt & Gulp Webpack & NPM tasks rule them all!
  • 3. Who? • Derek Stavis • Coding stuff since 2000
  • 4. Who? • Derek Stavis • Coding stuff since 2000 • High level stuff
  • 5. Who? • Derek Stavis • Coding stuff since 2000 • High level stuff • Low level stuff
  • 6. Who? • Derek Stavis • Coding stuff since 2000 • High level stuff • Low level stuff • Design stuff
  • 7. Who? • Derek Stavis • Coding stuff since 2000 • High level stuff • Low level stuff • Design stuff • github.com/derekstavis
  • 8. Who? • Derek Stavis • Coding stuff since 2000 • High level stuff • Low level stuff • Design stuff • github.com/derekstavis • github.com/oh-my-fish
  • 10. Gulp Configura:on File var app, base, concat, directory, gulp, hostname, path, refresh, sass, uglify, del, connect, autoprefixer, babel; var autoPrefixBrowserList = ['last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4']; gulp = require('gulp'); gutil = require('gulp-util'); concat = require('gulp-concat'); uglify = require('gulp-uglify'); sass = require('gulp-sass'); connect = require('gulp-connect'); del = require('del'); autoprefixer = require('gulp-autoprefixer'); babel = require('gulp-babel'); gulp.task('connect', function() { connect.server({ root: 'app', livereload: true }); }); gulp.task('images-deploy', function() { gulp.src(['app/images/**/*']) .pipe(gulp.dest('dist/images')); }); gulp.task('scripts', function() { //this is where our dev JS scripts are return gulp.src('app/scripts/src/**/*.js') .pipe(babel({ presets: ['es2015', 'react'] }) .pipe(concat('app.js')) .on('error', gutil.log) .pipe(uglify()) .pipe(gulp.dest('app/scripts')) .pipe(connect.reload()); }); gulp.task('scripts-deploy', function() { return gulp.src('app/scripts/src/**/ *.js') .pipe(concat('app.js')) .pipe(uglify()) .pipe(gulp.dest('dist/scripts')); }); gulp.task('styles', function() { return gulp.src('app/styles/scss/ init.scss') .pipe(sass({ errLogToConsole: true, includePaths: [ 'app/styles/scss/' ] })) .pipe(autoprefixer({ browsers: autoPrefixBrowserList, cascade: true })) .on('error', gutil.log) .pipe(concat('styles.css')) .pipe(gulp.dest('app/styles')) .pipe(connect.reload()); }); gulp.task('styles-deploy', function() { return gulp.src('app/styles/scss/ init.scss') .pipe(sass({ includePaths: [ 'app/styles/scss', ] })) .pipe(autoprefixer({ browsers: autoPrefixBrowserList, cascade: true })) .pipe(concat('styles.css')) .pipe(gulp.dest('dist/styles')); }); gulp.task('html', function() { return gulp.src('app/*.html') .pipe(connect.reload()) .on('error', gutil.log); }); gulp.task('html-deploy', function() { gulp.src('app/*') .pipe(gulp.dest('dist')); gulp.src('app/.*') .pipe(gulp.dest('dist')); gulp.src('app/fonts/**/*') .pipe(gulp.dest('dist/fonts')); gulp.src(['app/styles/*.css', '!app/styles/ styles.css']) .pipe(gulp.dest('dist/styles')); }); gulp.task('clean', function() { del('dist'); }); //this is our master task when you run `gulp` in CLI / Terminal //this is the main watcher to use when in active development // this will: // startup the web server, // start up livereload // compress all scripts and SCSS files gulp.task('default', ['connect', 'scripts', 'styles'], function() { gulp.watch('app/scripts/src/**', ['scripts']); gulp.watch('app/styles/scss/**', ['styles']); gulp.watch('app/*.html', ['html']); }); gulp.task('deploy', ['clean'], function () { gulp.start('scripts-deploy', 'styles- deploy', 'html-deploy', 'images-deploy'); });
  • 13. Build Pipeline → Webpack
 Task Management → NPM
  • 18. What is Webpack? • Module bundler
  • 19. What is Webpack? • Module bundler • Supercharges require
  • 20. What is Webpack? • Module bundler • Supercharges require • Anything is require-able
  • 21. What is Webpack? • Module bundler • Supercharges require • Anything is require-able • TransformaNons are based on loaders
  • 22. What is Webpack? • Module bundler • Supercharges require • Anything is require-able • TransformaNons are based on loaders • Other tasks can be implemented as plugins
  • 23. What is Webpack? • Module bundler • Supercharges require • Anything is require-able • TransformaNons are based on loaders • Other tasks can be implemented as plugins • Outputs assets in single or mulNple files
  • 24. What is Webpack? • Module bundler • Supercharges require • Anything is require-able • TransformaNons are based on loaders • Other tasks can be implemented as plugins • Outputs assets in single or mulNple files • Built-in hashing → Easy cache invalidaNons
  • 27. J S X How does Webpack?
  • 28. J S X J S ( E S 5 ) babel-loader How does Webpack?
  • 29. J S X J S ( E S 5 ) babel-loader S C S S How does Webpack?
  • 30. J S X J S ( E S 5 ) babel-loader S C S S C S S postcss-loader How does Webpack?
  • 31. J S X J S ( E S 5 ) babel-loader S C S S C S S postcss-loader P N G How does Webpack?
  • 32. J S X J S ( E S 5 ) babel-loader S C S S C S S postcss-loader P N G B A S E 6 4 file-loader How does Webpack?
  • 33. J S X J S ( E S 5 ) babel-loader S C S S C S S postcss-loader P N G B A S E 6 4 file-loader B U N D L E . J S How does Webpack?
  • 34. const path = require('path') const CopyPlugin = require('copy-webpack-plugin') module.exports = { entry: "./index.js", output: { path: path.join(__dirname, 'dist'), filename: "bundle.js" }, module: { loaders: [ { test: /.css$/, loader: "style!css" }, { test: /.js$/, loader: "babel" }, { test: /.(svg|ttf|otf|eot|woff|woff2|png|jpg|gif)$/, loader: "file" } ] }, plugins: [ new CopyPlugin([ { from: 'index.html' } ]), new Uglify([ { from: 'index.html' } ]) ] } Webpack Configura:on File
  • 36. Ok, but how we do tasks?
  • 37.
  • 38.
  • 40. What are NPM scripts
  • 41. What are NPM scripts
  • 42. • Custom commands through run-script What are NPM scripts
  • 43. • Custom commands through run-script • Pre-hooks for custom commands What are NPM scripts
  • 44. • Custom commands through run-script • Pre-hooks for custom commands • Include package binary entry points What are NPM scripts
  • 45. • Custom commands through run-script • Pre-hooks for custom commands • Include package binary entry points • Command composiNon What are NPM scripts
  • 48. IT’S DEMO TIME BYE GRUNT AND GULP