This repository shows examples of Webpack use, based on moisdujs-base basic javascript vanilla application.
WARNING this works only on Chrome
nodeJS & npm (see package.json engines for version)
All steps are branches. To test a step :
$ git co <branch>
$ npm i
$ npm run <script> (see package.json for details)
Refactor code to use webpack packaging (no Boostrap yet).
Include Bootstrap and jQuery dependencies.
Configure global jQuery module with Webpack ProvidePlugin.
Add filer-loader and url-loader to bundle Bootstrap glyphicons dependency.
Add extract-text-webpack-plugin to bundle css in a separate file.
Add eslint and eslint-loader, add preloader config to lint files before each webpack build.
Add compression plugin to gzip js and css bundles.
Add assets plugin and webpack configuration. Replace index.html by index.mustache. Add npm build script to generate index.html from template.
Add less loader and webpack configuration.
Use Webpack CommonsChunkPlugin to bundle vendors in a separate file. Add vendors import into index.mustache to generate script import as for the app.
Like step/8 but this time vendors entry reference a module that import all vendors (here bootstrap).
Move custom event to a event service, use require.ensure to lazy load it in code.
Add webpack dev server and configure npm scripts to build and start it. WARNING you can't use hashed bundles with webpack dev server, name changed brake reloading.
Upgrade webpack version to version 2. Change babel plugins, remove transform-es2015-modules-commonjs to enable tree shaking (we need to use native ES6 modules). Add some logic in events service to demonstrate tree shaking. To test, remove resetEvent in app.js import and build prod version.
Missing something? Fill an issue ;)
ISC