Basic skeleton, and dependencies

This commit is contained in:
Timothy Warren 2016-06-17 13:48:18 -04:00
parent 66e4ae2bdd
commit f4d3aa5023
10 changed files with 184 additions and 0 deletions

4
.gitignore vendored
View File

@ -92,3 +92,7 @@ jspm_packages
# Optional REPL history
.node_repl_history
# bundled javascript
/build/*.js
/build/*.js.map

11
index.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Arbor</title>
<!-- Add css here later -->
</head>
<body>
<main id="app"></main>
<script src="build/bundle.js"></script>
</body>
</html>

46
package.json Normal file
View File

@ -0,0 +1,46 @@
{
"name": "arbor-frontend",
"version": "1.0.0",
"description": "This is the frontend part of the Arbor application",
"main": "index.js",
"scripts": {
"start:dev": "webpack-dev-server",
"build": "webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors",
"build:watch": "webpack -w -d",
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js test/**/*.js",
"test:watch": "npm run test -- --watch"
},
"repository": {
"type": "git",
"url": "git@git.timshomepage.net:timw4mail/arbor-frontend.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"immutable": "^3.8.1",
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react-redux": "^4.4.5",
"react-router": "^2.4.1",
"redux": "^3.5.2"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"chai": "^3.5.0",
"mocha": "^2.5.3",
"postcss": "^5.0.21",
"postcss-cssnext": "^2.6.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"babel": {
"presets": [
"es2015",
"react"
]
}
}

7
src/action_creators.js Normal file
View File

@ -0,0 +1,7 @@
export function setState(state) {
}
export function update(item) {
}

19
src/app.js Normal file
View File

@ -0,0 +1,19 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {Router, Route, hashHistory} from 'react-router';
import {createStore} from 'redux';
import {Provider} from 'react-redux';
import reducer from './reducer';
import App from './components/App';
const store = createStore(reducer);
const routes = <Route component={App} />;
ReactDOM.render(
<Provider store={store}>
<Router history={hashHistory}>{routes}</Router>
</Provider>,
document.getElementById('app')
);

9
src/components/App.js Normal file
View File

@ -0,0 +1,9 @@
import React from 'react';
class App extends React.Component {
render() {
return this.props.children
}
}
export default App;

6
src/constants.js Normal file
View File

@ -0,0 +1,6 @@
/**
* 'Global' constants
*/
export const SET_STATE = 'SET_STATE';
export const UPDATE = 'UPDATE';
export const DELETE = 'DELETE';

22
src/reducer.js Normal file
View File

@ -0,0 +1,22 @@
import {Map} from 'immutable';
import * as CONST from './constants';
const actionMap = {
[CONST.SET_STATE]: (state) => {
}
};
/**
* Reducer function mapping action objects to state transition functions
*
* @param {Map} state
* @param {Object} action
* @return {Map}
*/
export default function reducer(state=Map(), action) {
// Return default state if action is undefined
if ( ! Object.keys(actionMap).includes(action)) {
return state;
}
}

21
test/test_helper.js Normal file
View File

@ -0,0 +1,21 @@
/**
* Fakes a browser environment for testing react
*/
import jsdom from 'jsdom';
import chai from 'chai';
import chaiImmutable from 'chai-immutable';
const doc = jsdom.jsdom('<!DOCTYPE html><html><body></body></html>');
const win = doc.defaultView;
global.document = doc;
global.window = win;
// Hoist window properties to global
Object.keys(window).forEach(key => {
if ( ! (key in global)) {
global[key] = window[key];
}
});
chai.use(chaiImmutable);

39
webpack.config.js Normal file
View File

@ -0,0 +1,39 @@
const webpack = require('webpack');
module.exports = {
cache: true,
debug: true,
devServer: {
contentBase: './build',
hot: true
},
devtool: 'sourcemaps',
entry: [
'webpack/hot/only-dev-server',
'./src/app.js',
],
module: {
loaders: [{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'react-hot!babel-loader'
}, {
test: /\.css$/,
loader: 'style-loader!css-loader!postcss-loader'
}]
},
output: {
path: `${__dirname}/build`,
publicPath: '/',
filename: 'bundle.js'
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
postcss: () => {
},
resolve: {
extensions: ['', '.js']
}
};