Updated README for webpack instructions (#412)

This commit is contained in:
mlucool 2016-07-05 01:50:01 -04:00 committed by Trent Mick
parent 32e4e2facf
commit 7c80e299f4

View file

@ -58,7 +58,7 @@ node.js library usage of bunyan in your apps.
- custom rendering of logged objects with ["serializers"](#serializers) - custom rendering of logged objects with ["serializers"](#serializers)
- [Runtime log snooping via DTrace support](#runtime-log-snooping-via-dtrace) - [Runtime log snooping via DTrace support](#runtime-log-snooping-via-dtrace)
- Support for a few [runtime environments](#runtime-environments): Node.js, - Support for a few [runtime environments](#runtime-environments): Node.js,
[Browserify](http://browserify.org/), [NW.js](http://nwjs.io/). [Browserify](http://browserify.org/), [Webpack](https://webpack.github.io/), [NW.js](http://nwjs.io/).
# Introduction # Introduction
@ -1149,6 +1149,7 @@ Node-bunyan supports running in a few runtime environments:
- [Node.js](https://nodejs.org/) - [Node.js](https://nodejs.org/)
- [Browserify](http://browserify.org/): See the - [Browserify](http://browserify.org/): See the
[Browserify section](#browserify) below. [Browserify section](#browserify) below.
- [Webpack](https://webpack.github.io/): See the [Webpack section](#webpack) below.
- [NW.js](http://nwjs.io/) - [NW.js](http://nwjs.io/)
Support for other runtime environments is welcome. If you have suggestions, Support for other runtime environments is welcome. If you have suggestions,
@ -1256,6 +1257,29 @@ var log = bunyan.createLogger({
log.info('hi on info'); log.info('hi on info');
``` ```
## Webpack
Webpack can work with the same example Browserify above. To do this, we need to make webpack ignore optional files:
Create "empty-shim.js":
```javascript
// This is an empty shim for things that should be not be included in webpack
```
Now tell webpack to use this file for
[optional dependencies](https://webpack.github.io/docs/configuration.html#resolve-alias)
in your "webpack.config.js":
```
resolve: {
// These shims are needed for bunyan
alias: {
'dtrace-provider': '/path/to/shim/empty_shim.js',
fs: '/path/to/shim/empty_shim.js',
'safe-json-stringify': '/path/to/shim/empty_shim.js',
mv: '/path/to/shim/empty_shim.js',
'source-map-support': '/path/to/shim/empty_shim.js'
}
}
```
Now webpack builds, ignoring these optional dependencies via shimming in an empty JS file!
# Versioning # Versioning
All versions are `<major>.<minor>.<patch>` which will be incremented for All versions are `<major>.<minor>.<patch>` which will be incremented for