48

js-library-boilerplate - A Webpack 4, Babel 7 Library Starter Pack

 5 years ago
source link: https://www.tuicool.com/articles/hit/RNZzymU
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
aimQVjv.png!web

Javascript Library Boilerplate

Library Starter Kit for your Javascript projects

:star:️ Features

  • Webpack 4
  • Babel 7
  • Hot Reloading ( npm start )
  • CSS Autoprefixer
  • UMD exports, so your library works everywhere.
  • Based on CRA v2.1.1 (For Vanilla JS libs or React libs)
  • Jest unit testing
  • npm run demo To build a ready-for-deployment demo (Example)
  • Customizable file headers for your build (Example 1) (Example2)
  • Configurable postinstall message (Example)
  • Weekly dependabot dependency updates

:package: Getting Started

git clone https://github.com/hodgef/js-library-boilerplate.git myLibrary
npm install

:gem: Customization

Before shipping, make sure to:
  1. Edit LICENSE file
  2. Edit package.json information (These will be used to generate the headers for your built files)
  3. Edit library: "MyLibrary" with your library's export name in ./config/webpack.config.prod.js
  4. Edit ./bin/postinstall (If you would like to display a message on package install)

:rocket: Deployment

npm publish

npm

import MyLibrary from 'my-library';
import 'my-library/build/index.css' // If you import a css file in your library
...

self-host/cdn

<link href="build/index.css" rel="stylesheet">
<script src="build/index.js"></script>

let MyLibrary from window.MyLibrary.default;
...

:white_check_mark: Libraries built with this boilerplate


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK