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
57
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Webpack Fundamentals
Beatriz Silveira
Cheesecake Labs
August 16, 2018
More Decks by Cheesecake Labs
See All by Cheesecake Labs
Cats' wellness & care
cheesecakelabs
0
79
How do we create the first impressions?
cheesecakelabs
0
89
Menstrual cup: suit and freedom
cheesecakelabs
0
110
Life is a cycle, better with a bicycle
cheesecakelabs
0
89
Interview Process: how to get the best of people
cheesecakelabs
1
140
My capsule wardrobe experience
cheesecakelabs
3
92
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
74
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
74
MBTI - Psychological types described by Jung
cheesecakelabs
0
170
Other Decks in Programming
See All in Programming
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
110
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
110
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
「人を評価する AI」の設計と実装
ryoyanara
0
200
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
160
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
260
メールのエイリアス機能を履き違えない
isshinfunada
0
240
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.4k
Google Apps Script で Ruby を動かす
kawahara
0
220
Cloudflare is Agents
chimame
0
160
Android CLI
fornewid
0
220
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
140
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
380
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Everyday Curiosity
cassininazir
0
280
Mobile First: as difficult as doing things right
swwweet
225
10k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Believing is Seeing
oripsolob
1
190
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.3k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
470
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