Visitar URL original
uswds/examples/webpack at develop · sitedata/uswds · GitHub
Skip to content

Latest commit

 

History

History
 
 

webpack

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

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 install

Once 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:js

Unlike 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.

JS bundling guidance

  • 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/export module syntax.