Tool to generate html pages based on facebook/react components.
Somewhat similar to (and somewhat inspired by) react-page.
Use npm, duh:
npm install -g react-builder
This registers the
We assume that the project directory for
mysite is laid out:
mysite/assets => static stuff: css, images, fonts... mysite/src => shared components mysite/src/pages => the actual pages mysite/srv => the output ready to be served mysite/package.json => npm package file to declare dependencies
A template for this structure can be seen in the awesomely named
react-builder-template repository. This also includes an example
core component for the page boilerplate along with placeholder index and
We can then run
react-builder in the
mysite directory. This will:
- Apply the jsx transform to all files under the
- Render html from each page in the src/pages directory.
- Browserify the js used to render each page.
- Uglify this js and insert it into the html.
- Output the finished page into the
- Watch for changes in the source files and update as required.
A version of React (hacked to be usable by browserify) can be found here: react-hack. Hopefully they will soon release a build that works sensibly with browserify anyway and this won't be needed...