Bundle npm package for browser
- Include the packages you want to bundle for browser
npm install --save pretty
- Edit
index.jsto export the functions you want to use
| var pretty = require('pretty'); | |
| // call myLibrary.pretty(...) inside browser after `<script src="dist/bundle.js"></script>` | |
| export { pretty }; |
| const path = require('path'); | |
| module.exports = { | |
| entry: './index.js', | |
| output: { | |
| filename: 'bundle.js', | |
| path: path.resolve(__dirname, 'dist'), | |
| library: 'myLibrary', | |
| libraryTarget : 'umd', | |
| }, | |
| optimization: { | |
| // minimize: false | |
| }, | |
| }; |