From 7c80e299f4fbe7a4b4e5979f2b39565cbe888e4b Mon Sep 17 00:00:00 2001 From: mlucool Date: Tue, 5 Jul 2016 01:50:01 -0400 Subject: [PATCH] Updated README for webpack instructions (#412) --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7bd2645..fa3275d 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ node.js library usage of bunyan in your apps. - custom rendering of logged objects with ["serializers"](#serializers) - [Runtime log snooping via DTrace support](#runtime-log-snooping-via-dtrace) - 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 @@ -1149,6 +1149,7 @@ Node-bunyan supports running in a few runtime environments: - [Node.js](https://nodejs.org/) - [Browserify](http://browserify.org/): See the [Browserify section](#browserify) below. +- [Webpack](https://webpack.github.io/): See the [Webpack section](#webpack) below. - [NW.js](http://nwjs.io/) Support for other runtime environments is welcome. If you have suggestions, @@ -1256,6 +1257,29 @@ var log = bunyan.createLogger({ 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 All versions are `..` which will be incremented for