Slide 1

Slide 1 text

Webpack pack your web Ly Cheng Modern Web 2015

Slide 2

Slide 2 text

LY yhsiang lyforever

Slide 3

Slide 3 text

國會無雙 市⻑⾧長給問

Slide 4

Slide 4 text

先調查⼀一下

Slide 5

Slide 5 text

Webpack module bundler

Slide 6

Slide 6 text

https://twitter.com/mjackson/status/584227818910777345

Slide 7

Slide 7 text

先講⼀一段故事

Slide 8

Slide 8 text

Uncaught Referencer Error jQuery is not defined

Slide 9

Slide 9 text

https://markb4.files.wordpress.com/2013/05/and-then-what-happened.jpeg

Slide 10

Slide 10 text

CommonJS vs AMD Server-side reuse vs Parallel loading

Slide 11

Slide 11 text

CommonJS AMD Works in the browser without build http://pichost.me/1835208/

Slide 12

Slide 12 text

But Finally, you have to build sth.

Slide 13

Slide 13 text

ES6 Harmony not ready for native browser

Slide 14

Slide 14 text

Not Only Javascript css, images, fonts, html ….

Slide 15

Slide 15 text

Assets pipeline In Rails, but now …

Slide 16

Slide 16 text

http://fccowasso.com/wp-content/uploads/2013/09/hope.jpg

Slide 17

Slide 17 text

http://webpack.github.io/

Slide 18

Slide 18 text

Webpack has Code Splitting Loaders Plugins Hot Module Replacement

Slide 19

Slide 19 text

http://webpack.github.io/docs/comparison.html Comparison Browserify vs Webpack blog.namangoel.com/browserify-vs-webpack-js-drama

Slide 20

Slide 20 text

Basic Usage

Slide 21

Slide 21 text

Configuration CLI and webpack.config.js

Slide 22

Slide 22 text

plugins devtool target

Slide 23

Slide 23 text

loaders preprocess files http://webpack.github.io/docs/loaders.html

Slide 24

Slide 24 text

loaders preprocess files http://webpack.github.io/docs/loaders.html pre-* / loaders / post-*

Slide 25

Slide 25 text

File loader filename template http://webpack.github.io/docs/loader-conventions.html url-loader, json-loader …

Slide 26

Slide 26 text

plugins make webpack flexible

Slide 27

Slide 27 text

Extract-text extract inline css to files

Slide 28

Slide 28 text

Code splitting load on demand idea from GWT

Slide 29

Slide 29 text

CommonJS: require.ensure AMD: require

Slide 30

Slide 30 text

{c, d} will be an additional chunk.

Slide 31

Slide 31 text

Stylesheets

Slide 32

Slide 32 text

require css create style element inline css extract-text-plugin css files

Slide 33

Slide 33 text

Shimming modules

Slide 34

Slide 34 text

require("imports?$=jquery!./file.js") var XModule = require("exports?XModule!./file.js")

Slide 35

Slide 35 text

Hot Module Replacement Livereload for every module

Slide 36

Slide 36 text

http://webpack.github.io/docs/hot-module-replacement-with-webpack.html

Slide 37

Slide 37 text

Entry webpack-dev-server/client? http://localhost:2992 webpack/hot/only-dev-server Plugins new webpack.HotModuleReplacementPlugin()

Slide 38

Slide 38 text

Webpack analyze

Slide 39

Slide 39 text

http://webpack.github.io/analyse/

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Webpack 2 webpack/concord

Slide 42

Slide 42 text

How We Use Webpack

Slide 43

Slide 43 text

Build with React watchout-tw/prototype-seed

Slide 44

Slide 44 text

Directory Structure component-based, SUITCSS

Slide 45

Slide 45 text

How about API

Slide 46

Slide 46 text

Proxy server webpack-dev-server and express use proxy option now!

Slide 47

Slide 47 text

Special thank to @tomchentw

Slide 48

Slide 48 text

Thank you

Slide 49

Slide 49 text

Recommendations https://github.com/petehunt/webpack-howto webpack-howto https://github.com/webpack/react-starter react-starter