This is a React introduction.
Follow the step by step tutorial by switching branches.
npm install --save [email protected]
npm install --save-dev gulp browserify babelify vinyl-source-streamCreate ./gulpfile.js with the following content
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
gulp.task('build', function () {
browserify({
entries: 'app/main.js',
extensions: ['.jsx', '.js'],
debug: true
})
.transform(babelify)
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('default', ['build']);Create ./app/main.js with the following content
import React from 'react';
React.render(
<h1>Hello World</h1>,
document.getElementById('react-root')
);Create ./dist/index.html with the following content
<!DOCTYPE html>
<html>
<body>
<div id="react-root"></div>
<script type="text/javascript" src="./js/bundle.js"></script>
</body>
</html>npm run build
open dist/index.html