Top Banner
002. WORKING WITH WEBPACK Presenter: Binh Quan
17

002. Working with Webpack

Mar 20, 2017

Download

Software

Binh Quan Duc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 002. Working with Webpack

002. WORKING WITH WEBPACK

Presenter: Binh Quan

Page 2: 002. Working with Webpack

Webpack

Page 3: 002. Working with Webpack

Webpack

❖ It can play as dev server❖ Help us create bundle for our application❖ Preprocess CSS, JS, images and more

Why use webpack

Page 4: 002. Working with Webpack

Read more: http://blog.andrewray.me/webpack-when-to-use-and-why/

Webpack

Why use webpack

Page 5: 002. Working with Webpack

❖ Dependency Graph

❖ Alias

❖ loaders

❖ Import/Export loader

❖ Plugin

❖ Code Splitting

❖ Polyfill

Webpack

What do we need to know about Webpack?

Page 6: 002. Working with Webpack

Webpack

Dependency Graph

Page 7: 002. Working with Webpack

Webpack

AliasWebpack.config.js, in ‘resolve’ section:

Using alias:

Page 8: 002. Working with Webpack

Webpack

LoadersLoaders allow you to preprocess files as you require() or “load” them

Page 9: 002. Working with Webpack

Webpack

Shimming - Import loaders

Page 10: 002. Working with Webpack

Webpack

Shimming - Export loaders

Page 11: 002. Working with Webpack

Webpack

Shimming - Expose loaders

See more at: https://webpack.github.io/docs/shimming-modules.html

There are cases where you want a module to export itself to the global context.

Page 12: 002. Working with Webpack

Webpack

PluginWebpack plugins have the ability to inject themselves into the build process to do all sorts of crazy stuff

Page 13: 002. Working with Webpack

This will remove all modules in the vendor chunk from the app chunk. The bundle.js will now contain just your app code, without any of its dependencies. These are in vendor.bundle.js.Read more: https://webpack.github.io/docs/code-splitting.html

Webpack

Code Splitting

Page 14: 002. Working with Webpack

Webpack

Fetch

Common libraries:❖ node-fetch❖ whatwg-fetch❖ isomorphic-

fetch

Page 15: 002. Working with Webpack

Webpack

Polyfill

Page 16: 002. Working with Webpack

Cons

❖ The document is awful

❖ Hard for beginner

Page 17: 002. Working with Webpack

Now Demo

❖ https://github.com/geniuscarrier/webpack-boilerplate❖ https://github.com/greenglobal/es6-babel-webpack-boilerp

late