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 and React
Search
sporto
March 03, 2015
Technology
4
390
Webpack and React
Webpack is a great fit for React.js applications, this decks explains the major features of Webpack
sporto
March 03, 2015
Tweet
Share
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
180
Elm
sporto
1
260
Redux: Flux Reduced
sporto
1
360
Practically Immutable
sporto
0
200
Rails with Webpack
sporto
1
220
Lesson learnt building Single Page Application
sporto
0
130
Grunt
sporto
1
190
Safe Testing in Ruby
sporto
1
130
Go - A great language for building web applications
sporto
1
340
Other Decks in Technology
See All in Technology
Kaggleコンペティション「MABe Challenge - Social Action Recognition in Mice」振り返り
yu4u
1
610
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
1.6k
サラリーマンソフトウェアエンジニアのキャリア
yuheinakasaka
42
19k
ドメイン駆動セキュリティへの道しるべ
pandayumi
0
150
Scrum Guide Expansion Pack が示す現代プロダクト開発への補完的視点
sonjin
0
800
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
3
410
20260120 Amazon VPC のパブリックサブネットを無くしたい!
masaruogura
2
140
Introduction to Bill One Development Engineer
sansan33
PRO
0
350
ソフトとハード両方いけるデータ人材の育て方
waiwai2111
1
530
SwiftDataを覗き見る
akidon0000
0
290
スクラムを一度諦めたチームにアジャイルコーチが入ってどう変化したか / A Team's Second Try at Scrum with an Agile Coach
kaonavi
0
270
Kusakabe_面白いダッシュボードの表現方法
ykka
0
350
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
82
The #1 spot is gone: here's how to win anyway
tamaranovitovic
1
890
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
120
30 Presentation Tips
portentint
PRO
1
190
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Prompt Engineering for Job Search
mfonobong
0
140
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Site-Speed That Sticks
csswizardry
13
1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
250
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
61
48k
Transcript
Webpack @sebasporto
React Components
Globals :( App.List = React.createClass({ ... }) React.render(<App.List />, ...)
? Will just pack everything
What we want = resolve dependencies Dead code
CommonJS :) module.exports = React.createClass({ ... }) var List =
require('./list') React.render(<List />, ...)
Webpack == Just what we need
★ CommonJS ★ AMD ★ ES6
Multiple entry points
/users /dashboard users-bundle.js dashboard-bundle.js
Entry points entry: { common: "./fe/ap/common.js", dashboard: "./fe/ap/dashboard.jsx", ... },
JSX JS ES6 Loaders Coffeescript
Loaders loaders: [ { test: /\.css/, loader: "style-loader!css-loader" }, {
test: /\.jsx$/, loader: "jsx-loader?stripTypes" }, ...
CSS Code Images Fonts JS JSX ES6 Coffee Less Sass
SVG Jpeg png eot ttf Templates
Loaders can have parameters Read JSX Remove Flow annotations Output
JS { test: /\.jsx$/, loader: "jsx-loader?stripTypes" },
Loaders can be chained Convert LESS to CSS Loads CSS
Inject CSS in document { test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
Interesting loaders ★ jsx loader ★ autoprefixer-loader
Images ★ base64 encoded ★ binary data as ASCII
Plug-ins
Operate on the entire bundles Interim bundles Source code Plug-ins
Final bundles
Plug-ins, e.g. ★ Stats ★ Uglify ★ Dedupe ★ Write
HTML ★ Localisations
Load on demand Split Chunk Chunk
On demand require.ensure(["foo", "bar"], function(require) { var foo = require("foo");
// ... }); load foo and bar on demand exec the rest when loaded
NPM integration ★ Install libs using NPM ★ Package.json for
dependencies ★ Use NPM packages from your code
Using webpack ★ npm install webpack -g ★ Create webpack.config.js
★ Run a watcher
Watcher $ webpack --watch Only rebuilds touched files
Or dev server $ webpack-dev-server <script src="http://localhost:8080/webpack-dev- server.js"></script> <script src="http://localhost:8080/js/foo-
bundle.js"></script>
Hot loader https://github.com/gaearon/react-hot-loader ★ Supposed to be great ★ I
haven't used it yet
For production Webpack Source code Development bundles Deployment Pipeline Production
bundles Sprockets
Dependency visualisation http://webpack.github.io/analyse/
Browserify? They do almost the same Plug-in based Batteries included
The bad parts: Documentation!
Resources ★ Official documentation == :( ★ https://github.com/ petehunt/webpack-howto ?
Webpack is brilliant Can do almost anything
Thanks!