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
0
45
Webpack Fundamentals
Beatriz Silveira
Cheesecake Labs
August 16, 2018
Tweet
Share
More Decks by Cheesecake Labs
See All by Cheesecake Labs
Cats' wellness & care
cheesecakelabs
0
56
How do we create the first impressions?
cheesecakelabs
0
65
Menstrual cup: suit and freedom
cheesecakelabs
0
81
Life is a cycle, better with a bicycle
cheesecakelabs
0
66
Interview Process: how to get the best of people
cheesecakelabs
1
96
My capsule wardrobe experience
cheesecakelabs
3
76
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
53
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
53
MBTI - Psychological types described by Jung
cheesecakelabs
0
150
Other Decks in Programming
See All in Programming
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2.5k
Apache Iceberg V3 and migration to V3
tomtanaka
0
160
CSC307 Lecture 04
javiergs
PRO
0
660
Patterns of Patterns
denyspoltorak
0
1.4k
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
110
MUSUBIXとは
nahisaho
0
130
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
170
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
Data-Centric Kaggle
isax1015
2
770
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
200
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
190
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
240
Why Our Code Smells
bkeepers
PRO
340
58k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
A better future with KSS
kneath
240
18k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
84
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
The SEO identity crisis: Don't let AI make you average
varn
0
240
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
420
The Cult of Friendly URLs
andyhume
79
6.8k
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