Last active
November 22, 2015 02:51
-
-
Save wrouesnel/8a411db83a4b258afac9 to your computer and use it in GitHub Desktop.
cerebral/browserify example case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by will on 6/09/15. | |
*/ | |
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var source = require('vinyl-source-stream'); | |
var browserify = require('browserify'); | |
var babelify = require('babelify'); | |
gulp.task('bundle', function() { | |
var bundler = browserify({debug:true, fullPaths: true}) | |
.transform("babelify", {presets: ["stage-0", "es2015", "react"]}) | |
.require('./main.js', { entry: true }); | |
return bundler.bundle() | |
.on("error", function(err) { | |
gutil.log('Browserify error:', err); | |
this.emit('end'); | |
}) | |
.pipe(source('./bundle.js')) | |
.pipe(gulp.dest('.')); | |
}); | |
gulp.task('default', ['bundle']); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta name="description" content="Simple Example"> | |
<meta name="viewport" content="width=device-width"> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script src="bundle.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {Container} from 'cerebral-react'; | |
import {Decorator as Cerebral} from 'cerebral-react'; | |
import ReactDOM from 'react-dom'; | |
import Controller from 'cerebral'; | |
import Model from 'cerebral-baobab'; | |
const model = Model({ | |
title: 'Bughunter' | |
}); | |
const services = {}; | |
const controller = Controller(model,services); | |
@Cerebral({ | |
title: ['title'] | |
}) | |
class App extends React.Component { | |
render() { | |
return ( | |
<div> | |
<h1>{this.props.title}</h1> | |
</div> | |
); | |
} | |
} | |
ReactDOM.render( | |
<Container controller={controller}> | |
<App/> | |
</Container> | |
, document.querySelector('#app') | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "cerebmin", | |
"version": "0.0.1", | |
"description": "a minimal example of a cerebral bug", | |
"main": "main.js", | |
"dependencies": { | |
"babel-preset-es2015": "^6.1.18", | |
"babel-preset-react": "^6.1.18", | |
"babel-preset-stage-0": "^6.1.18", | |
"babelify": "^7.2.0", | |
"baobab": "^2.1.1", | |
"browserify": "^12.0.1", | |
"cerebral": "^0.24.0", | |
"cerebral-baobab": "^0.4.2", | |
"cerebral-react": "^0.6.0", | |
"gulp": "^3.9.0", | |
"gulp-util": "^3.0.7", | |
"react": "^0.14.3", | |
"react-dom": "^0.14.3", | |
"vinyl-source-stream": "^1.1.0" | |
}, | |
"devDependencies": {}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment