Skip to content

Commit

Permalink
12.01 - Directory Structure
Browse files Browse the repository at this point in the history
  • Loading branch information
vasansr committed Dec 16, 2018
1 parent cab871c commit 32f3b28
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 14 deletions.
14 changes: 13 additions & 1 deletion commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ cd ui
npm install url-search-params@1
```

Chapter 11: React-Bootstrap
## Chapter 11: React-Bootstrap

### Installation
```
Expand All @@ -182,3 +182,15 @@ ln -s ../node_modules/bootstrap/dist public/bootstrap
cd ui
npm install react-router-bootstrap@0
```

## Chapter 12: Server Rendering

### Directory Structure
```
cd ui
mkdir browser
mkdir server
mv src/App.jsx browser
mv uiserver.js server
cp src/.babelrc browser
```
8 changes: 1 addition & 7 deletions ui/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"extends": "airbnb-base",
"env": {
"node": true
},
"rules": {
"no-console": "off"
}
"extends": "airbnb",
}
14 changes: 14 additions & 0 deletions ui/browser/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"ie": "11",
"edge": "15",
"safari": "10",
"firefox": "50",
"chrome": "49"
}
}],
"@babel/preset-react"
]
}
9 changes: 9 additions & 0 deletions ui/browser/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"env": {
"browser": true
},
rules: {
"import/extensions": [ 'error', 'always', { ignorePackages: true } ],
"react/prop-types": "off"
}
}
2 changes: 1 addition & 1 deletion ui/src/App.jsx → ui/browser/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom';

import Page from './Page.jsx';
import Page from '../src/Page.jsx';

const element = (
<Router>
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"#start": "UI server. HMR is enabled in dev mode.",
"start": "nodemon -w uiserver.js -w .env uiserver.js",
"start": "nodemon -w server -w .env server/uiserver.js",
"#lint": "Runs ESLint on all relevant files",
"lint": "eslint . --ext js,jsx --ignore-pattern public",
"#compile": "Generates JS bundles for production. Use with start.",
Expand Down
8 changes: 8 additions & 0 deletions ui/server/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"env": {
"node": true
},
"rules": {
"no-console": "off"
}
}
2 changes: 1 addition & 1 deletion ui/uiserver.js → ui/server/uiserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (enableHMR && (process.env.NODE_ENV !== 'production')) {
const devMiddleware = require('webpack-dev-middleware');
const hotMiddleware = require('webpack-hot-middleware');

const config = require('./webpack.config.js');
const config = require('../webpack.config.js');
config.entry.app.push('webpack-hot-middleware/client');
config.plugins = config.plugins || [];
config.plugins.push(new webpack.HotModuleReplacementPlugin());
Expand Down
4 changes: 2 additions & 2 deletions ui/src/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "airbnb",
"env": {
"browser": true
"browser": true,
"node": true
},
rules: {
"import/extensions": [ 'error', 'always', { ignorePackages: true } ],
Expand Down
2 changes: 1 addition & 1 deletion ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');

module.exports = {
mode: 'development',
entry: { app: ['./src/App.jsx'] },
entry: { app: ['./browser/App.jsx'] },
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'public'),
Expand Down

0 comments on commit 32f3b28

Please sign in to comment.