Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit c9b4d73

Browse files
committed
added examples directory and run script with webpack dev server
1 parent 2854a61 commit c9b4d73

File tree

6 files changed

+1789
-44
lines changed

6 files changed

+1789
-44
lines changed

examples/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>@cat-react/form - examples</title>
6+
</head>
7+
<body>
8+
<h1><a href="https://github.com/cat-react/form">@cat-react/form</a> - examples</h1>
9+
<ul>
10+
<li><a href="login/index.html">Simple Login</a></li>
11+
</ul>
12+
</body>
13+
</html>

examples/login/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
4+
class App extends React.Component {
5+
render() {
6+
return <div>Login</div>;
7+
};
8+
}
9+
10+
ReactDOM.render(<App />, document.getElementById('example'));

examples/login/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>@cat-react/form - examples - Login</title>
6+
</head>
7+
<body>
8+
<h1><a href="https://github.com/cat-react/form">@cat-react/form</a> - <a href="../index.html">examples</a> - Login</h1>
9+
<div id="example"></div>
10+
<script src="/build/vendor.bundle.js"></script>
11+
<script src="/build/login.js"></script>
12+
</body>
13+
</html>

examples/webpack.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var webpack = require('webpack');
4+
5+
module.exports = {
6+
devtool: 'inline-source-map',
7+
entry: fs.readdirSync(__dirname).reduce(function (entries, dir) {
8+
const isDir = fs.lstatSync(path.join(__dirname, dir)).isDirectory();
9+
10+
if (isDir) {
11+
entries[dir] = path.join(__dirname, dir, 'app.js');
12+
}
13+
14+
return entries;
15+
}, {}),
16+
output: {
17+
path: path.join(__dirname, 'build'),
18+
filename: '[name].js',
19+
chunkFilename: '[id].chunk.js',
20+
publicPath: '/build/'
21+
},
22+
module: {
23+
loaders: [
24+
{
25+
test: /\.js$/,
26+
exclude: /node_modules/,
27+
loader: 'babel-loader',
28+
query: {
29+
presets: ['es2015', 'react']
30+
}
31+
}
32+
]
33+
},
34+
resolve: {
35+
alias: {
36+
'@cat-react/form': '../../src'
37+
}
38+
},
39+
plugins: [
40+
new webpack.optimize.CommonsChunkPlugin('vendor.bundle')
41+
]
42+
};

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"license": "MIT",
99
"scripts": {
1010
"test": "./node_modules/.bin/jest",
11-
"lint": "./node_modules/.bin/eslint src/**/*"
11+
"lint": "./node_modules/.bin/eslint src/**/*",
12+
"examples": "./node_modules/.bin/webpack-dev-server --config examples/webpack.config.js --content-base examples --open --hot"
1213
},
1314
"dependencies": {
1415
"auto-bind": "^1.1.0",
@@ -17,6 +18,7 @@
1718
"devDependencies": {
1819
"babel-eslint": "^7.2.3",
1920
"babel-jest": "^20.0.3",
21+
"babel-loader": "^7.1.2",
2022
"babel-plugin-transform-class-properties": "^6.24.1",
2123
"babel-plugin-transform-decorators-legacy": "^1.3.4",
2224
"babel-preset-es2015": "^6.24.1",
@@ -28,7 +30,9 @@
2830
"jest": "^20.0.4",
2931
"react": "^15.6.1",
3032
"react-dom": "^15.6.1",
31-
"react-test-renderer": "^15.6.1"
33+
"react-test-renderer": "^15.6.1",
34+
"webpack": "^3.5.5",
35+
"webpack-dev-server": "^2.7.1"
3236
},
3337
"peerDependencies": {
3438
"react": ">= 15.0.0 < 17.0.0"

0 commit comments

Comments
 (0)