Webpack based boilerplate for producing libraries (Input: ES6, Output: universal library)
Webpack based boilerplate for producing libraries (Input: ES6, Output: universal library)
Webpack based boilerplate for producing libraries (Input: ES6/TypeScript, Output: universal library)
ES6/TypeScript source files
|
|
webpack
|
+--- babel
|
ready to use
library
in umd formatHave in mind that you have to build your library before publishing. The files under the lib folder are the ones that should be distributed.
webpack.config.js file and change the value of libraryName variable.package.json file and change the value of main property so it matches the name of your library.yarn install (recommended) or npm install to get the project's dependenciesyarn build to produce minified version of your library.yarn dev. This command will generate a non-minified version of your library and will run a watcher so you get the compilation on file change.yarn testyarn build - produces production version of your library under the lib folderyarn build-amd - produces an AMD version that works with RequireJSyarn dev - produces development version of your library and runs a watcheryarn dev-amd - produces an AMD development version of your library and runs a watcheryarn test - well ... it runs the tests :)yarn test-watch - same as above but in a watch modeIn the following example we are excluding React and Lodash:
{
devtool: 'source-map',
output: {
path: '...',
libraryTarget: 'umd',
library: '...'
},
entry: '...',
...
externals: {
react: 'react'
// Use more complicated mapping for lodash.
// We need to access it differently depending
// on the environment.
lodash: {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: '_',
root: '_'
}
}
}No open issues yet, or sync has not completed.