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
41
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
49
How do we create the first impressions?
cheesecakelabs
0
53
Menstrual cup: suit and freedom
cheesecakelabs
0
57
Life is a cycle, better with a bicycle
cheesecakelabs
0
51
Interview Process: how to get the best of people
cheesecakelabs
1
81
My capsule wardrobe experience
cheesecakelabs
3
58
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
37
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
45
MBTI - Psychological types described by Jung
cheesecakelabs
0
130
Other Decks in Programming
See All in Programming
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
1
310
XSLTで作るBrainfuck処理系
makki_d
0
210
A comprehensive view of refactoring
marabesi
0
970
Passkeys for Java Developers
ynojima
3
880
AIネイティブなプロダクトをGolangで挑む取り組み
nmatsumoto4
0
120
無関心の谷
kanayannet
0
180
ReadMoreTextView
fornewid
1
450
A2A プロトコルを試してみる
azukiazusa1
2
820
すべてのコンテキストを、 ユーザー価値に変える
applism118
2
430
Effect の双対、Coeffect
yukikurage
5
1.4k
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
1
120
来たるべき 8.0 に備えて React 19 新機能と React Router 固有機能の取捨選択とすり合わせを考える
oukayuka
2
820
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.9k
Product Roadmaps are Hard
iamctodd
PRO
53
11k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Music & Morning Musume
bryan
46
6.6k
Typedesign – Prime Four
hannesfritz
42
2.7k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.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