Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Webpack Fundamentals
Search
Cheesecake Labs
August 16, 2018
Programming
50
0
Share
Webpack Fundamentals
Beatriz Silveira
Cheesecake Labs
August 16, 2018
More Decks by Cheesecake Labs
See All by Cheesecake Labs
Cats' wellness & care
cheesecakelabs
0
69
How do we create the first impressions?
cheesecakelabs
0
75
Menstrual cup: suit and freedom
cheesecakelabs
0
92
Life is a cycle, better with a bicycle
cheesecakelabs
0
75
Interview Process: how to get the best of people
cheesecakelabs
1
120
My capsule wardrobe experience
cheesecakelabs
3
82
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
63
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
64
MBTI - Psychological types described by Jung
cheesecakelabs
0
160
Other Decks in Programming
See All in Programming
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
150
The Less-Told Story of Socket Timeouts
coe401_
3
990
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
490
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
200
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
540
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
770
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
330
tRPCの概要と少しだけパフォーマンス
misoton665
2
270
My daily life on Ruby
a_matsuda
3
190
【26新卒研修資料】TDD実装演習
dip_tech
PRO
0
170
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
390
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
150
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Leo the Paperboy
mayatellez
7
1.7k
How to Ace a Technical Interview
jacobian
281
24k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
So, you think you're a good person
axbom
PRO
2
2k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
370
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
180
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Done Done
chrislema
186
16k
Writing Fast Ruby
sferik
630
63k
Raft: Consensus for Rubyists
vanstee
141
7.4k
Transcript
Webpack Fundamentals
Origins
JS it's just scripts
Inline Script
Problems • Doesn't Scale • Too many Scripts • Performance
Problems • Unmaintainable Scripts • Scope • Size • Readability • Fragility
IIFE's - Immediately Invoked Function Expression
IIFE's • Full rebuilds every time • Lots of IIFE's
are slow
How to import JS on Backend? COMMON JS
CommonJS -> NodeJS
JavaScript Modules CommonJS
JavaScript Modules Was too popular, but how to use this
on Browser Commonjs is synchronous !!! No browser support !!! CommonJS
AMD To transfer module syntax from server usage to browser
usage, CommonJS proposed AMD - Asynchronous Module Definition
AMD But, How can I use it ?
RequireJS • Is a JavaScript module loader. • It helps
load modules asynchronously as needed • You can write AMD style module
RequireJS
Browserify • With Browserify, you can use CommonJS module in
browser application • Traverse the dependency tree of your codes and bundle them up in a single file
Browserify
ES6 Module Syntax • Browsers are not ready for this
new syntax. • There are tools available. These tools allow us to use ES6 module syntax today.
Webpack • Webpack is a module bundler. • If it
is the same as Browserify, why would we need yet another module bundler? • Webpack can handle CommonJS, AMD and ES6 modules.
The Core Concepts • Entry • Output • Loaders •
Plugins
Entry Default ./src/index.js webpack.config.js
Output Default ./dist/main.js
Loaders & Rules test A regular expression that instructs the
compiler which files to run the loader against. use An array/string/function that returns loader objects.
Chaining Loaders less-loader css-loader style-loader style.less style.css *.js Inline style
Plugins Allow you to hook into the entire compilation lifecycle
Add new instance of plugin to plugins key in config object
Using during development 1. Webpack's watch mode 2. webpack-dev-server
Webpack's Watch Mode npm run watch
webpack -dev-server webpack.config.js
webpack -dev-server package.json
Tree Shaking Dead-code elimination
Tree Shaking
Tree Shaking
Production Goal - Improve load time 1. Minified bundles 2.
Lighter weight source maps 3. Optimized assets It's recommend writing separate webpack configurations for each environment