Skip to content

Instantly share code, notes, and snippets.

Avatar

Evgeniy Serykh evserykh

View GitHub Profile
View App.jsx
import React from 'react';
import { BrowserRouter, Link, Route } from 'react-router-dom';
import HelloWorld from './HelloWorld';
const App = () => (
<BrowserRouter>
<div>
<ul>
<li>
View package.json
{
"license": "MIT",
"scripts": {
"dev:server": "node src/js/server.dev.js"
},
"dependencies": {
"express": "^4.14.1",
"pug": "^2.0.0-beta11",
"react": "^15.4.2",
"react-dom": "^15.4.2"
@evserykh
evserykh / HelloWorld.jsx
Last active Feb 17, 2017
HelloWorld.jsx
View HelloWorld.jsx
import React from 'react';
const HelloWorld = props => <h1>Hello World from {props.location.pathname}</h1>;
export default HelloWorld;
View index.js
import React from 'react';
import { render } from 'react-dom';
import App from './components/App';
render(<App />, document.getElementById('root'));
View .babelrc
{
"presets": [
["es2015", { "modules": false }],
"react",
"stage-0"
]
}
View webpack.dev.config.js
var path = require('path');
var config = {
entry: path.join(__dirname, 'src/js/index.js'),
output: {
path: '/',
publicPath: 'http://localhost:3000/',
filename: 'bundle.js'
},
View index.pug
doctype html
html
head
meta(charset='UTF-8')
title React Universal App
body
#root
script(src='/bundle.js')
View server.dev.js
var express = require('express');
var path = require('path');
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackConfig = require(path.join(__dirname, '../../webpack.dev.config.js'));
var app = express();
var compiler = webpack(webpackConfig);
app.set('view engine', 'pug');
You can’t perform that action at this time.