diff --git a/packages/generator-react-server/generators/app/templates/gulpfile.js b/packages/generator-react-server/generators/app/templates/gulpfile.js new file mode 100644 index 000000000..156852c6e --- /dev/null +++ b/packages/generator-react-server/generators/app/templates/gulpfile.js @@ -0,0 +1,12 @@ +const gulp = require('gulp'); +const tagger = require('react-server-gulp-module-tagger'); +const babel = require('gulp-babel'); + +gulp.task('default', () => { + gulp.src('*.js') + .pipe(tagger()) + .pipe(babel({ + presets: ['react-server'] + })) + .pipe(gulp.dest('build')); +}); diff --git a/packages/generator-react-server/generators/app/templates/hello-world.js b/packages/generator-react-server/generators/app/templates/hello-world.js index 9bf38e2c6..ffee4fcd9 100644 --- a/packages/generator-react-server/generators/app/templates/hello-world.js +++ b/packages/generator-react-server/generators/app/templates/hello-world.js @@ -1,10 +1,14 @@ import React from 'react'; +import {logging} from 'react-server'; + +const logger = logging.getLogger(__LOGGER__); export default class HelloWorld extends React.Component { constructor(props) { super(props); this.state = {exclamationCount: 0}; this.handleClick = () => { + logger.info(`Getting more excited! previously ${this.state.exclamationCount} excitements.`); this.setState({exclamationCount: this.state.exclamationCount + 1}); }; } diff --git a/packages/generator-react-server/generators/app/templates/package.json b/packages/generator-react-server/generators/app/templates/package.json index b90a92953..cff3f4b2b 100644 --- a/packages/generator-react-server/generators/app/templates/package.json +++ b/packages/generator-react-server/generators/app/templates/package.json @@ -4,7 +4,7 @@ "description": "A react-server instance", "main": "HelloWorld.js", "scripts": { - "start": "react-server-cli", + "start": "gulp && react-server-cli --routes build/routes.js", "test": "xo && nsp check" }, "license": "Apache-2.0", @@ -20,14 +20,19 @@ "superagent": "1.2.0" }, "devDependencies": { + "babel-preset-react-server": "^0.2.0", "eslint-config-xo-react": "^0.7.0", "eslint-plugin-react": "^5.1.1", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", "nsp": "^2.3.3", + "react-server-gulp-module-tagger": "^0.2.6", "xo": "^0.15.1" }, "xo": { "esnext": true, "extends": "xo-react", + "globals": ["__LOGGER__"], "ignores": ["__clientTemp/**/*"] } } diff --git a/packages/generator-react-server/package.json b/packages/generator-react-server/package.json index 0932d677b..907c8c395 100644 --- a/packages/generator-react-server/package.json +++ b/packages/generator-react-server/package.json @@ -38,12 +38,11 @@ }, "license": "Apache-2.0", "xo": { + "envs": ["node"], "extends": "xo-react", + "globals": ["__LOGGER__"], "ignores": [ "test/**/*" - ], - "envs": [ - "node" ] } }