Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Webpack Fundamentals

Webpack Fundamentals

Beatriz Silveira

Cheesecake Labs

August 16, 2018
Tweet

More Decks by Cheesecake Labs

Other Decks in Programming

Transcript

  1. Problems • Doesn't Scale • Too many Scripts • Performance

    Problems • Unmaintainable Scripts • Scope • Size • Readability • Fragility
  2. JavaScript Modules Was too popular, but how to use this

    on Browser Commonjs is synchronous !!! No browser support !!! CommonJS
  3. AMD To transfer module syntax from server usage to browser

    usage, CommonJS proposed AMD - Asynchronous Module Definition
  4. RequireJS • Is a JavaScript module loader. • It helps

    load modules asynchronously as needed • You can write AMD style module
  5. 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
  6. 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.
  7. 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.
  8. 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.
  9. Plugins Allow you to hook into the entire compilation lifecycle

    Add new instance of plugin to plugins key in config object
  10. 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