Last active
August 29, 2015 14:27
-
-
Save gocreating/70fdb6d97fd20aed97cb to your computer and use it in GitHub Desktop.
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 Router from 'react-router'; | |
import routes from '../routes'; | |
Router.run(routes, Router.HistoryLocation, (Handler) => { | |
React.render(<Handler />, document.getElementById('react-container')); | |
}); |
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
export default (app) => { | |
app.get('/*', (req, res) => { | |
res.send(` | |
<html> | |
<head> | |
</head> | |
<body> | |
<div id="react-container"></div> | |
<script src="http://localhost:3001/core/js/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
// server modules | |
import http from 'http'; | |
// settings | |
import settings from '../settings'; | |
export default (app) => { | |
/** | |
* http server | |
*/ | |
http | |
.createServer(app) | |
.listen(3000, () => { | |
console.log('HTTP server listening on port', port); | |
}); | |
var webpack = require('webpack'); | |
var WebpackDevServer = require('webpack-dev-server'); | |
var config = require(process.cwd() + '/gulp/webpack.development.js'); | |
new WebpackDevServer(webpack(config), { | |
hot: true, | |
quiet: false, | |
noInfo: false, | |
historyApiFallback: true, | |
proxy: { | |
'*': 'http://localhost:3000', | |
}, | |
stats: { | |
colors: true, | |
}, | |
}).listen(3001, 'localhost', function(err, result) { | |
if (err) { | |
console.log(err); | |
} | |
console.log('Listening at localhost:3001'); | |
}); | |
}; |
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
var path = require('path'); | |
var webpack = require('webpack'); | |
var nodeModulesDir = path.join(__dirname, '../node_modules'); | |
var deps = [ | |
'react/dist/react.min.js', | |
'react-router/umd/ReactRouter.min.js', | |
]; | |
var webpackconfig = { | |
entry: [ | |
'webpack/hot/only-dev-server', | |
'webpack-dev-server/client?http://localhost:3001', | |
path.resolve(__dirname, '../src/core/flux/boot.js'), | |
], | |
output: { | |
path: path.resolve(__dirname, '../build/debug/core/public/js'), | |
filename: 'bundle.js', | |
}, | |
resolve: { | |
alias: {}, | |
}, | |
module: { | |
noParse: [], | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
loaders: ['react-hot-loader', 'babel-loader'], | |
exclude: [nodeModulesDir, /node_modules/], | |
}, | |
], | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NoErrorsPlugin(), | |
], | |
}; | |
deps.forEach(function(dep) { | |
var depPath = path.resolve(nodeModulesDir, dep); | |
webpackconfig.resolve.alias[dep.split(path.sep)[0]] = depPath; | |
webpackconfig.module.noParse.push(depPath); | |
}); | |
module.exports = webpackconfig; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment