1 | # rc-server
|
2 |
|
3 | development server for react component
|
4 |
|
5 | [![NPM version][npm-image]][npm-url]
|
6 | [![gemnasium deps][gemnasium-image]][gemnasium-url]
|
7 | [![node version][node-image]][node-url]
|
8 | [![npm download][download-image]][download-url]
|
9 |
|
10 | [npm-image]: http://img.shields.io/npm/v/rc-server.svg?style=flat-square
|
11 | [npm-url]: http://npmjs.org/package/rc-server
|
12 | [travis-image]: https://img.shields.io/travis/react-component/rc-server.svg?style=flat-square
|
13 | [travis-url]: https://travis-ci.org/react-component/rc-server
|
14 | [coveralls-image]: https://img.shields.io/coveralls/react-component/rc-server.svg?style=flat-square
|
15 | [coveralls-url]: https://coveralls.io/r/react-component/rc-server?branch=master
|
16 | [gemnasium-image]: http://img.shields.io/gemnasium/react-component/rc-server.svg?style=flat-square
|
17 | [gemnasium-url]: https://gemnasium.com/react-component/rc-server
|
18 | [node-image]: https://img.shields.io/badge/node.js-%3E=_0.11-green.svg?style=flat-square
|
19 | [node-url]: http://nodejs.org/download/
|
20 | [download-image]: https://img.shields.io/npm/dm/rc-server.svg?style=flat-square
|
21 | [download-url]: https://npmjs.org/package/rc-server
|
22 |
|
23 | ## Feature
|
24 |
|
25 | * support jsx
|
26 | * support autoprefixer
|
27 | * support mocha-phantomjs
|
28 | * support travis
|
29 | * support coveralls.io
|
30 | * support react js module render as html
|
31 | * support load commonjs file into browser and run
|
32 |
|
33 |
|
34 | ## Usage
|
35 |
|
36 | ### file structure
|
37 |
|
38 | ```
|
39 | - .travis.yml
|
40 | - examples
|
41 | - index.html
|
42 | - index.js
|
43 | - lib
|
44 | - Component.js
|
45 | - index.js
|
46 | - tests
|
47 | - index-spec.js
|
48 | - package.json
|
49 | ```
|
50 |
|
51 | Suggest using https://github.com/react-component/generator-rc
|
52 |
|
53 | #### index.js
|
54 |
|
55 | ```js
|
56 | /** @jsx React.DOM */
|
57 | var Component = require('./lib/Component');
|
58 | module.exports = <Component />
|
59 | ```
|
60 |
|
61 | #### Component.js
|
62 |
|
63 | ```js
|
64 | /** @jsx React.DOM */
|
65 | var React = require('react');
|
66 | var Component = React.createClass({
|
67 | // TODO
|
68 | render: function(){
|
69 | return <div></div>;
|
70 | };
|
71 | });
|
72 | module.exports = Component;
|
73 | ```
|
74 |
|
75 | #### .travis.yml
|
76 |
|
77 | ```
|
78 | language: node_js
|
79 | node_js:
|
80 | - 0.11
|
81 | before_script:
|
82 | - npm start &
|
83 | - npm install mocha-phantomjs -g
|
84 | - phantomjs --version
|
85 | script:
|
86 | - npm test
|
87 | - npm run browser-test
|
88 | - npm run browser-test-cover
|
89 | ```
|
90 |
|
91 | #### package.json
|
92 |
|
93 | ```js
|
94 | {
|
95 | "devDependencies": {
|
96 | "rc-server": "^1.0.0"
|
97 | },
|
98 | "config": {
|
99 | "port": 8001
|
100 | },
|
101 | "scripts": {
|
102 | "start": "node --harmony node_modules/.bin/rc-server",
|
103 | "browser-test": "mocha-phantomjs http://localhost:$npm_package_config_port/tests/runner.html",
|
104 | "browser-test-cover": "mocha-phantomjs -R node_modules/rc-server/node_modules/node-jscover/lib/reporters/mocha/console http://localhost:$npm_package_config_port/tests/runner.html?coverage"
|
105 |
|
106 | }
|
107 | }
|
108 | ```
|
109 |
|
110 | #### index-spec.js
|
111 |
|
112 | ```js
|
113 | var expect = require('expect.js');
|
114 | var React = require('react');
|
115 | var Component = require('../');
|
116 |
|
117 | describe('it', function(){
|
118 | it('works', function(){
|
119 | var component = (<Component/><a></a></Component>);
|
120 | expect(component).to.be(component);
|
121 | });
|
122 | });
|
123 | ```
|
124 |
|
125 | #### index.html
|
126 |
|
127 | ```
|
128 | placeholder
|
129 | ```
|
130 |
|
131 | remove backslash!
|
132 |
|
133 | Suggest using https://github.com/react-component/generator-rc
|
134 |
|
135 | ### start server
|
136 |
|
137 | ```
|
138 | npm install
|
139 | npm start
|
140 | ```
|
141 |
|
142 | * open [http://localhost:8001/tests/runner.html](http://localhost:8001/tests/runner.html) to see test
|
143 | * open [http://localhost:8001/examples/index.md](http://localhost:8001/examples/index.html) to see demo |
\ | No newline at end of file |