Using the Design System with webpack 2
This example illustrates how to bundle the USWDS JavaScript with webpack version 2 and npm.
First, install the dependencies with npm:
npm installOnce you've done this, you can modify src/js/main.js and run
the following command to build js/main.js and its complimentary source map:
npm run build:jsUnlike browserify, webpack automatically converts ES2015 to
ES5 and resolves import and export statements. The -p ("production") and
--devtool sourcemap options to the webpack CLI enable minification and
source map generation, respectively.
See the browserify CLI docs for more information.
- Because webpack 2 understands ES2015 natively, it's safe to use one of the above techniques import the original sources.
- As of this writing, it's not possible to take advantage of tree shaking because the Standards source JavaScript doesn't use the
import/exportmodule syntax.