Skip to content

Commit 31c160d

Browse files
committedNov 10, 2014
switch to web pack dev server for examples
1 parent 5497538 commit 31c160d

File tree

6 files changed

+68
-15
lines changed

6 files changed

+68
-15
lines changed
 

‎CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ always be in sync.
2828

2929
### Development
3030

31-
- `script/test` will fire up a karma runner and watch for changes in the
32-
specs directory.
33-
- `npm test` will do the same but doesn't watch, just runs the tests.
34-
- `script/build-examples` does exactly that.
31+
- `npm start` runs the dev server to run/develop examples
32+
- `npm test` will run the test.
33+
- `script/test` same as `npm test` but keeps karma running and watches
34+
for changes
3535

3636
### Build
3737

‎examples/basic/index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<link href="app.css" rel="stylesheet"/>
55
<body>
66
<div id="example"></div>
7-
<script src="../global-bundle.js"></script>
8-
<script src="app-bundle.js"></script>
7+
<script src="/__build__/shared.js"></script>
8+
<script src="/__build__/basic.js"></script>
9+

‎package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"example": "examples"
1414
},
1515
"scripts": {
16-
"test": "script/test --browsers Firefox --single-run"
16+
"test": "script/test --browsers Firefox --single-run",
17+
"start": "script/dev-examples"
1718
},
1819
"authors": [
1920
"Ryan Florence"
@@ -24,6 +25,7 @@
2425
"browserify-shim": "3.6.0",
2526
"envify": "1.2.0",
2627
"expect": "0.1.1",
28+
"jsx-loader": "0.11.2",
2729
"karma": "0.12.16",
2830
"karma-browserify": "^0.2.1",
2931
"karma-chrome-launcher": "0.1.4",
@@ -35,7 +37,8 @@
3537
"react-tap-event-plugin": "git://github.com/appsforartists/react-tap-event-plugin",
3638
"reactify": "^0.14.0",
3739
"rf-release": "0.3.1",
38-
"uglify-js": "2.4.15"
40+
"uglify-js": "2.4.15",
41+
"webpack-dev-server": "1.6.5"
3942
},
4043
"peerDependencies": {
4144
"react": ">=0.11.0"
@@ -55,4 +58,4 @@
5558
"browserify-shim": {
5659
"react": "global:React"
5760
}
58-
}
61+
}

‎script/build-examples

-6
This file was deleted.

‎script/dev-examples

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
node_modules/.bin/webpack-dev-server --inline --content-base examples/
3+

‎webpack.config.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var webpack = require('webpack');
4+
5+
var EXAMPLES_DIR = path.resolve(__dirname, 'examples');
6+
7+
function isDirectory(dir) {
8+
return fs.lstatSync(dir).isDirectory();
9+
}
10+
11+
function buildEntries() {
12+
return fs.readdirSync(EXAMPLES_DIR).reduce(function (entries, dir) {
13+
if (dir === 'build')
14+
return entries;
15+
16+
var isDraft = dir.charAt(0) === '_';
17+
18+
if (!isDraft && isDirectory(path.join(EXAMPLES_DIR, dir)))
19+
entries[dir] = path.join(EXAMPLES_DIR, dir, 'app.js');
20+
21+
return entries;
22+
}, {});
23+
}
24+
25+
module.exports = {
26+
27+
entry: buildEntries(),
28+
29+
output: {
30+
filename: '[name].js',
31+
chunkFilename: '[id].chunk.js',
32+
path: 'examples/__build__',
33+
publicPath: '/__build__/'
34+
},
35+
36+
module: {
37+
loaders: [
38+
{ test: /\.js$/, loader: 'jsx-loader?harmony' }
39+
]
40+
},
41+
42+
resolve: {
43+
alias: {
44+
'react-router': '../../modules/index'
45+
}
46+
},
47+
48+
plugins: [
49+
new webpack.optimize.CommonsChunkPlugin('shared.js')
50+
]
51+
52+
};

0 commit comments

Comments
 (0)
Please sign in to comment.