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
39
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
45
How do we create the first impressions?
cheesecakelabs
0
47
Menstrual cup: suit and freedom
cheesecakelabs
0
48
Life is a cycle, better with a bicycle
cheesecakelabs
0
44
Interview Process: how to get the best of people
cheesecakelabs
1
70
My capsule wardrobe experience
cheesecakelabs
3
49
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
32
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
41
MBTI - Psychological types described by Jung
cheesecakelabs
0
110
Other Decks in Programming
See All in Programming
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
230
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Realtime API 入門
riofujimon
0
150
Quine, Polyglot, 良いコード
qnighy
4
650
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
170
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
230
C++でシェーダを書く
fadis
6
4.1k
Featured
See All Featured
Code Review Best Practice
trishagee
64
17k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Why Our Code Smells
bkeepers
PRO
334
57k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
100
Faster Mobile Websites
deanohume
305
30k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Being A Developer After 40
akosma
87
590k
Building an army of robots
kneath
302
43k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
A designer walks into a library…
pauljervisheath
204
24k
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