SlideShare a Scribd company logo
Advanced front-end automation

with npm scripts
@k88hudson
Mozilla
<3 @brycebaril @dark_rost_ruth
Who writes code for browsers?
I love browsers
I hate build tools
“Systems tend to grow, and as they grow, they encroach”

“Systems tend to expand to fill the known universe.”
—John Gall, The Systems Bible
The more complex and self-sufficient the
automated system, the more difficult it
will be understand and operate.
The Paradoxes and Ironies of Automation, David Wentzel. 

http://www.davewentzel.com/content/paradoxes-and-ironies-automation
Advanced front-end automation with npm scripts
1. Takes advantage of the natural interface presented

by its component parts;
2. Breaks down complex things into simple,

composable things;
3. Makes compromises intentionally, not
circumstantially
Your system can win, if it:
Why npm scripts?
npm scripts =
shell + node + npm =
magic
Advanced front-end automation with npm scripts
npm scripts can:
transpile es2015, transpile jsx, minify/optimize code, optimize svgs, copy,
rename and move files, compile css via a pre-processor, add autoprefixing,
source maps for js/css development, build Android and Firefox OS apps from
source with cordova, run unit tests, run code linting, run style checking,
run test coverage reporting, deploy releases, run watch for developer
environment and live reload dev server, etc. etc. etc.
in twenty lines or less, with zero plugins.
Let’s dive in!
Why is the npm script environment
better at dealing with our problems?
You already use node, npm
npm run
package.json usage
npm run
package.json usage
npm run environment
node executables via npmshell $PATH
{npm lifecycle
bash/cmd.exe -> good at:
File i/o
Chaining tasks
Running tasks in series/parallel
Cross-compatible!
rutabaga input.js | uglifyjs > output.js
tomato && cucumber && cauliflower
bash / node
cat / catw
mkdir / mkdirp
rm / rimraf
& / npm-run-all —parallel
npm run: $PATH
Works!
A good automated system takes advantage of the

natural interface presented by its component parts
Plugins add an extra layer
Most tools already have a cli
browserify
webpack
mocha
lessc
joshing
eslint
sass
uglifyjs
svgo
karma
Browserify
“browserify -d -t reactify ./entry.js -o ./output.js”
module.exports = function(grunt) {
grunt.initConfig({
browserify: {
options: {
debug: true,
transform: ['reactify']
},
files: {
'./output.js': './entry.js'
}
},
});
grunt.loadNpmTasks('grunt-browserify');
grunt.registerTask('default', ['browserify']);
};
Advanced front-end automation with npm scripts
Webpack
Advanced front-end automation with npm scripts
npm run environment
node executables via npmshell $PATH
{npm lifecycle
Lifecycle scripts
npm install
npm publish
npm version
npm version patch -m "Upgrade to %s for lolz"
> commit 522d0 “Upgrade to v0.0.1 for lolz”
> new tag v0.0.1
"scripts": {
"preversion": "npm run test && npm run build”,
"postversion": "npm publish && git push --tags"
}
pre- and post-
npm run potato
> prepotato
SO HUNGRY
> potato
mashing...
done.
> postpotato
YUM YUM
A good automated system breaks down
complex things into simple, composable things
http://www.infoq.com/presentations/Simple-Made-Easy
“Simple Made Easy”
Components of an automated system are simple

when they have a single, well-defined objective.


Good complex tasks are composed

of well-defined simple ones.
Baseline
Sub-tasks
Sub-tasks with npm-run-all
Name-spaced sub-tasks
Complete example
Advanced front-end automation with npm scripts
What are the trade offs?
Simpler mental models instead of
performance.
Less code, but less extensible
Shell scripting is still hard, especially
maintaining cross-compatibility with Windows.
We need to build more tools, a

set of common “recipes”… and more?
What can you do?
- Try it out, talk about what’s hard
- Work on cross-platform bugs
- Share your recipes
- File bugs or help improve npm docs
Go forth and script!

Show me what you build @k88hudson

More Related Content

Similar to Advanced front-end automation with npm scripts (20)

PDF
Containers: The What, Why, and How
Sneha Inguva
 
PDF
Workshop 3: JavaScript build tools
Visual Engineering
 
PPTX
Vagrant and chef
Nick Ramirez
 
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
ZIP
Zenoss: Buildout
Jeffrey Clark
 
PDF
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
PPT
Automated Penetration Testing With The Metasploit Framework
Tom Eston
 
PDF
S&T What I know about Node 110817
Dan Dineen
 
PPTX
Automation of Active Directory's Deployments on AWS
Devoteam Revolve
 
PPTX
Intro To Node.js
Chris Cowan
 
PDF
PuppetDB: Sneaking Clojure into Operations
grim_radical
 
PDF
Our Puppet Story (Linuxtag 2014)
DECK36
 
PPTX
Large Scale Crash Dump Analysis with SuperDump
Christoph Neumüller
 
PDF
Zotonic presentation Erlang Camp Boston, august 2011
Arjan
 
PPTX
Front end development gurant
marwa Ayad Mohamed
 
PPTX
Infrastructure as code - Python Saati #36
Halil Kaya
 
PDF
Ganeti Web Manager: Cluster Management Made Simple
OSCON Byrum
 
PPTX
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
Is Antipov
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PDF
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
DevOpsDays Riga
 
Containers: The What, Why, and How
Sneha Inguva
 
Workshop 3: JavaScript build tools
Visual Engineering
 
Vagrant and chef
Nick Ramirez
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
Zenoss: Buildout
Jeffrey Clark
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
Automated Penetration Testing With The Metasploit Framework
Tom Eston
 
S&T What I know about Node 110817
Dan Dineen
 
Automation of Active Directory's Deployments on AWS
Devoteam Revolve
 
Intro To Node.js
Chris Cowan
 
PuppetDB: Sneaking Clojure into Operations
grim_radical
 
Our Puppet Story (Linuxtag 2014)
DECK36
 
Large Scale Crash Dump Analysis with SuperDump
Christoph Neumüller
 
Zotonic presentation Erlang Camp Boston, august 2011
Arjan
 
Front end development gurant
marwa Ayad Mohamed
 
Infrastructure as code - Python Saati #36
Halil Kaya
 
Ganeti Web Manager: Cluster Management Made Simple
OSCON Byrum
 
Automatic deployment on .NET web stack (Minsk .NET meetup 12.02.14)
Is Antipov
 
Intro to Node.js (v1)
Chris Cowan
 
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
DevOpsDays Riga
 

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Python basic programing language for automation
DanialHabibi2
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
July Patch Tuesday
Ivanti
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Ad

Advanced front-end automation with npm scripts