This skeleton repo is a starter for creating an npm module to be used as a library in your main app.
- webpack for bundling
- babel to support writting the library in ES2015
- mocha as a test runner with chai for assertions
- eslint for linting
- Clone the repo
- Delete the .git directory and then run
git init
to start tracking your history - Update package.json with your info (project name, urls, author info, license, keywords, basically everything)
There are many different npm scripts in the package.json to support various workflows. Here are the highlights, but you can run npm run
to list them all.
npm run dev
will watch files for changes then build and test themnpm test
will run all unit tests in the./test
directory and it's subdirectoriesnpm run lint
will lint all source and test files. Note that linting also happens during the buildnpm run verify
will lint the files, then run the tests. Useful for CInpm run build
will bundle the library as both minified and unminified and with sourcemaps.npm run demo
will use webpack-dev-server to serve up a demo app that is using the library. Changes to library or demo app will cause a reload of the page.
To use the demo page from the browser serve up the this directory with something like http-server or python and pull up navigate to demo/index.html
The building blocks for this skeleton came from this article by Krasimir Tsonev: http://krasimirtsonev.com/blog/article/javascript-library-starter-using-webpack-es6.
This talk by Kate Hudson greatly influenced how npm scripts are being used: https://youtu.be/0RYETb9YVrk.