Giter Club home page Giter Club logo

warp-guides-webpack's Introduction

WEBPACK BEGINNERS GUIDE

About

This is a quick, on demand and yet unedited/untested guide how to set up webpack build system (in the moment you drop gulp on when you haven't used any building/packing system before).

Originally this was written in times when webpack just came out and documentation, both official as well as users', was sparse and bad. Now there are many excellent Hello World as well as in in-depth tutorials on webpack. Many projects offer boilerplates to study from. But I try to keep this up to date anyways.

Put together by @kroko for the new colleagues that see webpack for the first time. However I tried to formulate things in a way so that other random readers may also benefit.
While doing edits I realised that notes should be made for some basic npm stuff as the reality is - there are people who haven't used any building tools or even npm before (not-Node.js backend guys - PHP/ROR/... - leaning towards full stack of frontend), but want to jump in webpack. So this assumes entry level knowledge in Node/NPM.

Chapters

1. webpack says Hello World

  • OS requirements
  • Directory structure
  • npm
  • Server side
  • First build of JavaScript
  • Webpack mode, deploy tiers and environments (NODE_ENV)
  • JavaScript modules and webpack resolve alias
  • Minimise JavaScript with custom options
  • Copy files to destination without compiling
  • First build of SCSS/CSS
  • Scope hoisting
  • Define plugin
  • npm scripts

2. SCSS, CSS, PostCSS settings

  • PostCSS
  • Bootstrapping CSS with normalize.css
  • CSS source maps
  • Making SCSS tier aware

3. File loading

  • File loading
  • Image compressing
  • Font loading (example for old bulletproof syntax)

4. webpack DevServer and hot reloading

  • Custom properties.json (helper) file
  • webpack DevServer setup
  • CORS
  • making it hot

5. HTML building, asset injecting and inlining, cache busting

  • HTML building
  • Cache busting by using hashes
  • Inline manually managed files into HTML
  • Minify HTML including inlined code

6. Babel

  • Short explanation what Babel does
  • Installing Babel
  • Core
  • preset-env
  • babelrc
  • Babel loader
  • Module system and Tree Shaking
  • Babel polyfill and browserslist
  • Babel plugins
  • Other polyfills
  • Shims

7. Linting JavaScript and CSS/SCSS

  • ESLint
  • JavaScript Standard Style with ;
  • Stylelint

8. Analysing bundle and code chunk splitting

  • Analysing the built products
  • The issue that code splitting solves
  • Code splitting setup
  • Different approaches - common, vendor a.o. chunks
  • Chunk naming
  • Lazy loading
  • Runtime (webpack Manifest)
  • Inlining Runtime

9. PWA and TTFMP

  • Serverside and TLS
  • Valet or warp-serve-localhost
  • Web App Manifest
  • Service worker
  • Test offline and Audit
  • Preload links
  • Preload async chunks

Assumptions

  • As of writing webpack version is 4.41.5.

Node.js / npm version

This tut has been tested on node 12.13.1 / npm 6.13.2. Latest LTS, at least node version 8.x+, npm version 5.7.1+ (note that webpack 5 will drop support for node 8 and will support 10.13+)

Todo / notes to self

  • Expand on TTFMP stuff
  • Expand on PWA stuff
  • Discuss how webpack-dev-server can be launched via API

License

The MIT License.

warp-guides-webpack's People

Contributors

kroko avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.