forked from redfin/react-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix redfin#37: Add README for react-server-gulp-module-tagger
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# react-server-gulp-module-tagger | ||
|
||
A [gulp](http://gulpjs.com) plugin for tagging [react-server](https://www.npmjs.com/package/react-server) logger instances with information about the module they're being used in. | ||
|
||
To transpile your source for use with [React Server](https://www.npmjs.com/package/react-server), install gulp and the plugin | ||
|
||
npm i -D gulp react-server-gulp-module-tagger | ||
|
||
Then add the task to your gulpfile | ||
|
||
const gulp = require('gulp'); | ||
const tagger = require('react-server-gulp-module-tagger'); | ||
gulp.task('compile', () => { | ||
gulp.src('src') | ||
.pipe(tagger()) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
Compile task might also use [Babel](https://babeljs.io) with the [React Server Babel preset](https://www.npmjs.com/package/babel-preset-react-server) | ||
|
||
const gulp = require('gulp'); | ||
const babel = require('gulp-babel'); | ||
const tagger = require('react-server-gulp-module-tagger'); | ||
|
||
gulp.task('compile', () => { | ||
gulp.src('src') | ||
.pipe(tagger()) | ||
.pipe(babel({ presets: ['react-server'] })) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
Given a [React Server](https://www.npmjs.com/package/react-server) getLogger call, adds the correct arguments to keep the server and the browser in sync. | ||
|
||
For example, given the following three files | ||
|
||
#### src/foo.js | ||
const logger = require("react-server").logging.getLogger(__CACHE__); | ||
|
||
#### src/bar.js | ||
let logger = require("react-server").logging.getLogger(__LOGGER__); | ||
|
||
#### src/baz.js | ||
var logger = require("react-server").logging.getLogger(__CHANNEL__); | ||
|
||
Would transpile to logger instances with consistent names and colors on both the server and the client. |