Webpack starter kit for creating libraries (Input: ES6, Output: UMD, CommonJS)
- Webpack 4
- Babel 7
- ES6 as a source
- Exports in UMD and CommonJS
- ES6 test setup with Mocha and Chai
- Test coverage with nyc command-line-client for Istanbul
- Linting with ESLint
- Basic Travis configuration
- Open
webpack.config.js
and change the value oflibraryName
variable with your library's name. - Open
package.json
and change the following properties with your library's equivalentname
version
description
main
repository
author
license
bugs
homepage
- Run
npm install
to install the library's dependencies.
- Having all the dependencies installed run
npm run dev
. This command will generate aUMD
unminified bundle under thedist
folder and aCommonJS
bundle under thelib
folder. It will also watch for changes in source files to recompile.
- Having all the dependencies installed run
npm run build
. This command will generate twoUMD
bundles (unminified and minified) under thedist
folder and aCommonJS
bundle under thelib
folder.
npm run build
- Produces production version of library underdist
folder for UMD bundle andlib
folder forCommonJS
bundle.npm run build:umd
- Produces an unminified UMD bundle under thedist
folder.npm run build:umdmin
- Produces an minified UMD bundle under thedist
folder.npm run build:commonjs
- Produces a CommonJS bundle under thelib
folder.npm run dev
- Produces a development version of library (both UMD and CommonJS) and runs a watcher to watch for changes.npm run dev:umd
- Produces an unminified UMD bundle under thedist
folder and runs a watcher to watch for changes.npm run dev:commonjs
- Produces a CommonJS bundle under thelib
folder and runs a watcher to watch for changes.npm run test
- Runs the tests.npm run coverage
- Runs the tests and provides with test coverage information.npm run lint
- Lints the source code with ESlint.npm run clean
- Deletesdist
,lib
andcoverage
folders.npm run prepare
- Run both BEFORE the package is packed and published, on local npm install without any arguments, and when installing git dependencies.
- By default all source code is located under the
src
folder. - Be default
dist
andlib
folders are excluded from source control but included for npm. You can change this behavior by not excluding these folders inside the.gitignore
file. - The starter kit assumes that all tests are located under
test
folder with.spec.js
extension.