Skip to content

Commit 2e251b1

Browse files
committed
bug 해결하기
1 parent 732aa8b commit 2e251b1

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

lessons/01-setting-up/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<!doctype html public "storage">
1+
<!doctype html public="storage">
22
<html>
33
<meta charset=utf-8/>
4-
<link rel="stylesheet" href="index.css" />
4+
<link rel="stylesheet" href="/index.css">
55
<title>My First React Router App</title>
66
<div id=app></div>
7-
<script src="bundle.js"></script>
7+
<div>aaaa</div>
8+
<!--<script src="/bundle.js"></script>-->

lessons/01-setting-up/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import React from 'react'
22
import { render } from 'react-dom'
33
import App from './modules/App'
4-
import { Router, Route, hashHistory, IndexRoute} from 'react-router';
4+
import { Router, Route, hashHistory, IndexRoute, browserHistory} from 'react-router';
55

66
import About from './modules/About';
77
import Repos from './modules/Repos';
8-
98
import Repo from './modules/Repo'
10-
119
import Home from './modules/Home'
1210

1311
render((
14-
<Router history={hashHistory}>
12+
<Router history={browserHistory}>
1513
<Route path="/" component={App}>
16-
17-
{/* add it here, as a child of '/' */}
1814
<IndexRoute component={Home}/>
19-
2015
<Route path="/repos" component={Repos}>
2116
{/* add this new route*/}
2217
<Route path="/repos/:userName/:repoName" component={Repo}/>

lessons/01-setting-up/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"start": "webpack-dev-server --inline --content-base ."
7+
"start" : "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
8+
"start:dev" : "webpack-dev-server --inline --content-base . --history-api-fallback",
9+
"start:prod" : "webpack && node server.js"
810
},
911
"author": "",
1012
"license": "ISC",
1113
"dependencies": {
14+
"compression": "^1.6.2",
15+
"express": "^4.14.0",
16+
"if-env": "^1.0.0",
1217
"react": "^0.14.7",
1318
"react-dom": "^0.14.7",
1419
"react-router": "^2.0.0"

lessons/01-setting-up/server.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var express = require('express')
2+
var path = require('path')
3+
4+
var app = express()
5+
6+
app.use(express.static(__dirname))
7+
8+
app.get('*', function(req, res) {
9+
res.sendFile(path.join(__dirname, 'index.html'))
10+
})
11+
12+
var PORT = process.env.PORT || 8080
13+
14+
app.listen(PORT, function(){
15+
console.log('Production Express server running at localhost:' + PORT)
16+
})

lessons/01-setting-up/webpack.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ module.exports = {
22
entry: './index.js',
33

44
output: {
5-
filename: 'bundle.js',
6-
publicPath: ''
5+
path : 'public',
6+
filename: 'bundle.js',
7+
publicPath: '/'
78
},
89

910
module: {

0 commit comments

Comments
 (0)