Skip to content

Commit b3ef504

Browse files
committed
依存ライブラリの更新 fix #20 fix #21
1 parent 8496821 commit b3ef504

File tree

10 files changed

+109
-113
lines changed

10 files changed

+109
-113
lines changed

README.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ sample-ui-react
1717
1.`npm install -g gulp` 」 を実行して Gulp をインストール。
1818
- Mac ユーザは 「 `sudo npm install -g gulp` 」 で。
1919
1. コンソールで本ディレクトリ直下へ移動後、 「 `npm install` 」 を実行して Gulp ライブラリをインストール。
20-
- Windows ユーザは 「 npm install --msvs_version=2013 」 。理由は後述
21-
22-
---
23-
24-
標準で利用想定の [BrowserSync](http://www.browsersync.io/) は LiveReload よりも同期が早く開発生産性に大きく寄与しますが、 Windows ユーザの場合は [Python2.7](https://www.python.org/)[Visual Studio 2013 Update N](https://www.visualstudio.com/downloads/download-visual-studio-vs) のインストールが必須となります。
25-
*`Express 2013 for Desktop` を推奨します。 ( 手元で試したところ `Community 2015` では正しく動きませんでした ) *
20+
- node-sass あたりでビルドに失敗した場合は、 「 `npm uninstall node-sass` 」 を実行してから再度試してみてください。
2621

2722
### 動作確認
2823

@@ -33,17 +28,15 @@ sample-ui-react
3328
- application.yml の `extension.security.auth.enabled` を true にして起動すればログイン機能の確認も可能
3429
1. コンソールで本ディレクトリ直下へ移動し、 「 `gulp` 」 を実行
3530
- 確認用のブラウザが自動的に起動する。うまく起動しなかったときは 「 http://localhost:3000 」 へアクセス
36-
- 画面が白く表示されてしまう時はブラウザの更新を押してみてください
37-
- webpack のビルドが間に合っていない可能性が高いため
3831

3932
### 開発の流れ
4033

41-
基本的にテンプレート ( .jade / .scss / .js ( ES6 ) ) を Web リソース ( .html / .css / .js ) へ Gulp / Webpack でリアルタイム変換させながら開発をしていきます。
34+
基本的にテンプレート ( .pug / .scss / .js ( ES6 ) ) を Web リソース ( .html / .css / .js ) へ Gulp / Webpack でリアルタイム変換させながら開発をしていきます。
4235
動作確認は Gulp で独自に Web サーバを立ち上げた後、ブラウザ上で行います。
4336

4437
#### 各種テンプレートファイルの解説
4538

46-
- [Jade](http://jade-lang.com/)
39+
- [Pug](https://github.com/pugjs/pug)
4740
- HTML を生成するテンプレートツール。公式サイト TOP にある簡素な記法が特徴。
4841
- [Sass (SCSS)](http://sass-lang.com/)
4942
- CSS 表記を拡張するツール。変数や mixin 、ネスト表記などが利用可能。
@@ -88,8 +81,8 @@ public … deploy resources (auto generate)
8881
- style.css … from source/css
8982
fonts … icon font
9083
js
91-
- bundler.js … from source/js (by Webpack)
92-
- vendor.js … from vendor dist resource
84+
- bundle.js … from source/js (by Webpack)
85+
- vendor.bundle.js … from vendor dist resource
9386
index.html … from source/html
9487
source
9588
css … css template files [SCSS]
@@ -117,18 +110,18 @@ source
117110

118111
| ライブラリ | バージョン | 用途/追加理由 |
119112
| ----------------------- | -------- | ------------- |
120-
| `superagent` | 1.7.+ | HTTP 連携ライブラリ |
121-
| `react`               | 0.14.+ | アプリケーションの UI 機能を提供 |
122-
| `react-dom`           | 0.14.+ | アプリケーションの UI 機能 ( DOM ) を提供 |
123-
| `react-router` | 0.13.+ | React.js の SPA ルーティングサポート |
113+
| `superagent` | 2.3.+ | HTTP 連携ライブラリ |
114+
| `react`          | 15.4.+ | アプリケーションの UI 機能を提供 |
115+
| `react-dom`        | 15.4.+ | アプリケーションの UI 機能 ( DOM ) を提供 |
116+
| `react-router` | 3.0.+ | React.js の SPA ルーティングサポート |
124117
| `react-mixin` | 3.0.+ | Reactクラス利用時のMixin拡張 |
125-
| `wolfy87-eventemitter` | 4.3.+ | イベント連携ライブラリ |
126-
| `flux` | 2.1.+ | Facebook Flux ライブラリ |
127-
| `lodash`              | 4.6.+ | 汎用ユーティリティライブラリ |
128-
| `dateformat`          | 1.0.+ | 日時ライブラリ |
129-
| `jquery` | 2.2.+ | DOM 操作サポート |
118+
| `wolfy87-eventemitter` | 5.1.+ | イベント連携ライブラリ |
119+
| `flux` | 3.1.+ | Facebook Flux ライブラリ |
120+
| `lodash`          | 4.17.+ | 汎用ユーティリティライブラリ |
121+
| `dateformat`       | 2.0.+ | 日時ライブラリ |
122+
| `jquery` | 3.1.+ | DOM 操作サポート |
130123
| `bootstrap-sass` | 3.3.+ | CSS フレームワーク |
131-
| `fontawesome` | 4.5.+ | フォントアイコンライブラリ |
124+
| `fontawesome` | 4.6.+ | フォントアイコンライブラリ |
132125

133126
### License
134127

gulpfile.babel.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,15 @@ const paths = {
2424
}
2525
const resource = {
2626
src: {
27-
jade: `${paths.src.html}/**/*.jade`,
27+
pug: `${paths.src.html}/**/*.pug`,
2828
webpack: {
2929
babel: `${paths.src.js}/**/*.(js|jsx)`
3030
},
3131
sass: `${paths.src.css}/**/*.s+(a|c)ss`,
3232
static: `${paths.src.static}/**/*`
3333
},
3434
vendor: {
35-
js: {
36-
jquery: `${paths.node.modules}/jquery/dist/jquery.js`,
37-
bootstrap: `${paths.node.modules}/bootstrap-sass/assets/javascripts/bootstrap.js`,
38-
eventemitter: `${paths.node.modules}/wolfy87-eventemitter/EventEmitter.js`
39-
},
35+
js: ['jquery', 'lodash', 'dateformat', "wolfy87-eventemitter", 'react', 'react-dom', "react-router", 'bootstrap-sass'],
4036
fontawesome: `${paths.node.modules}/font-awesome/fonts/**/*`
4137
}
4238
}
@@ -61,7 +57,7 @@ gulp.task('default', ['build', 'server'])
6157

6258
//## build for developer
6359
gulp.task('build', (callback) =>
64-
runSequence('clean', ['build:jade', 'build:sass', 'build:webpack', 'build:static'], callback)
60+
runSequence('clean', ['build:pug', 'build:sass', 'build:webpack', 'build:static'], callback)
6561
)
6662

6763
//## build production
@@ -85,13 +81,21 @@ gulp.task('revision', (callback) =>
8581
// compile Webpack [ ES6(Babel) / Vue -> SPA(main.js) ]
8682
gulp.task('build:webpack', () => {
8783
process.env.NODE_ENV = (production == true) ? 'production' : 'development'
88-
let plugins = [ new webpack.optimize.DedupePlugin() ]
89-
if (production) plugins.push(new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }}))
84+
let plugins = [
85+
new webpack.optimize.DedupePlugin(),
86+
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js"),
87+
new webpack.ProvidePlugin({jQuery: "jquery", $: "jquery"})
88+
]
89+
if (production) plugins.push(new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }, sourceMap: false }))
9090
return gulp.src(resource.src.webpack.babel)
9191
.pipe($.plumber())
9292
.pipe(webpackStream({
93-
entry: `${paths.src.js}/main.js`,
94-
output: {filename: 'bundler.js'},
93+
devtool: '#source-map',
94+
entry: {
95+
app: `${paths.src.js}/main.js`,
96+
vendor: resource.vendor.js
97+
},
98+
output: {filename: 'bundle.js'},
9599
watch: !production,
96100
module: {
97101
loaders: [
@@ -108,11 +112,11 @@ gulp.task('build:webpack', () => {
108112
.pipe(browserSync.stream())
109113
})
110114

111-
// compile Jade -> HTML
112-
gulp.task('build:jade', () => {
113-
return gulp.src(resource.src.jade)
115+
// compile Pug -> HTML
116+
gulp.task('build:pug', () => {
117+
return gulp.src(resource.src.pug)
114118
.pipe($.plumber())
115-
.pipe($.jade())
119+
.pipe($.pug())
116120
.pipe($.htmlhint())
117121
.pipe($.htmlhint.reporter())
118122
.pipe(gulp.dest(paths.dist.root))
@@ -132,11 +136,6 @@ gulp.task('build:sass', () => {
132136

133137
// copy Static Resource
134138
gulp.task('build:static', () => {
135-
const libs = resource.vendor.js
136-
gulp.src(Object.keys(libs).map((key) => libs[key]))
137-
.pipe($.concat("vendor.js"))
138-
.pipe($.if(production, $.uglify()))
139-
.pipe(gulp.dest(paths.dist.js))
140139
gulp.src(resource.vendor.fontawesome)
141140
.pipe(gulp.dest(paths.dist.font))
142141
return gulp.src(resource.src.static)

package.json

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sample-ui-react",
3-
"version": "0.2.2",
3+
"version": "0.3.0",
44
"description": "React.js Boilerplate",
55
"main": "source/js/main.js",
66
"scripts": {
@@ -13,54 +13,55 @@
1313
"type" : "git",
1414
"url" : "https://github.com/jkazama/sample-ui-react.git"
1515
},
16+
"dependencies": {
17+
"bootstrap-sass": "~3.3.0",
18+
"co": "~4.6.0",
19+
"dateformat": "~2.0.0",
20+
"font-awesome": "~4.6.0",
21+
"jquery": "~3.1.0",
22+
"lodash": "~4.17.0",
23+
"superagent": "~2.3.0",
24+
"react": "~15.4.0",
25+
"react-dom": "~15.4.0",
26+
"react-router": "~3.0.0",
27+
"react-mixin": "~3.0.0",
28+
"wolfy87-eventemitter": "~5.1.0",
29+
"flux": "~3.1.0"
30+
},
1631
"devDependencies": {
17-
"gulp": "~3.9.0",
18-
"gulp-load-plugins": "~1.2.0",
32+
"babel-core": "~6.18.0",
33+
"babel-loader": "~6.2.0",
34+
"babel-plugin-transform-runtime": "~6.15.0",
35+
"babel-preset-es2015": "~6.14.0",
36+
"babel-runtime": "~6.18.0",
37+
"browser-sync": "~2.17.0",
38+
"css-loader": "~0.25.0",
1939
"del": "~2.2.0",
20-
"run-sequence": "~1.1.5",
21-
"gulp-if": "2.0.0",
22-
"gulp-slash": "1.1.3",
23-
"gulp-order": "1.1.1",
24-
"gulp-changed": "1.3.0",
40+
"gulp": "~3.9.0",
41+
"gulp-changed": "~1.3.0",
2542
"gulp-concat": "~2.6.0",
26-
"gulp-plumber": "~1.0.1",
27-
"gulp-jade": "~1.1.0",
28-
"gulp-htmlhint": "~0.3.0",
29-
"gulp-sass": "~2.1.1",
30-
"gulp-pleeease": "~2.0.2",
31-
"gulp-uglify": "~1.5.1",
3243
"gulp-cssmin": "~0.1.0",
33-
"gulp-rev-all": "~0.8.22",
34-
"webpack": "~1.12.14",
35-
"webpack-stream": "~3.1.0",
44+
"gulp-htmlhint": "~0.3.0",
45+
"gulp-if": "~2.0.0",
46+
"gulp-load-plugins": "~1.2.0",
47+
"gulp-order": "~1.1.0",
48+
"gulp-pleeease": "~2.0.0",
49+
"gulp-plumber": "~1.1.0",
50+
"gulp-pug": "~3.0.0",
51+
"gulp-rev-all": "~0.8.0",
52+
"gulp-sass": "~2.3.0",
53+
"gulp-slash": "~1.1.0",
54+
"gulp-uglify": "~1.5.0",
3655
"html-loader": "~0.4.0",
37-
"template-html-loader": "~0.0.3",
38-
"css-loader": "~0.23.1",
56+
"node-sass": "~3.13.0",
57+
"pug": "~2.0.0-beta6",
58+
"pug-loader": "~2.3.0",
59+
"run-sequence": "~1.2.0",
60+
"sass-loader": "~4.0.0",
3961
"style-loader": "~0.13.0",
40-
"sass-loader": "~3.1.2",
41-
"node-sass": "~3.4.2",
42-
"jade-loader": "~0.8.0",
43-
"babel-loader": "~6.2.4",
44-
"babel-core": "~6.9.0",
45-
"babel-runtime": "~6.9.0",
46-
"babel-plugin-transform-runtime": "~6.9.0",
47-
"babel-preset-es2015 ": "~6.9.0",
48-
"babel-preset-react ": "~6.5.0",
49-
"browser-sync": "~2.11.0"
50-
},
51-
"dependencies": {
52-
"co": "~4.6.0",
53-
"superagent": "~1.7.2",
54-
"react": "~0.14.7",
55-
"react-dom": "~0.14.7",
56-
"react-router": "~0.13.5",
57-
"react-mixin": "~3.0.3",
58-
"wolfy87-eventemitter": "~4.3.0",
59-
"flux": "~2.1.1",
60-
"lodash": "~4.6.0",
61-
"dateformat": "~1.0.12",
62-
"jquery": "~2.2.1",
63-
"bootstrap-sass": "~3.3.6",
64-
"font-awesome": "~4.5.0"
62+
"template-html-loader": "~0.0.3",
63+
"webpack": "~1.13.0",
64+
"webpack-stream": "~3.2.0",
65+
"babel-preset-react ": "~6.22.0"
6566
}
6667
}

source/html/index.jade renamed to source/html/index.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ html(lang="ja")
55
meta(content="IE=edge,chrome=1" http-equiv="X-UA-Compatible")
66
title アプリケーション
77
link(rel="stylesheet" href="/css/style.css")
8-
script(src="/js/vendor.js")
8+
script(src="/js/vendor.bundle.js")
99
body
1010
#app
11-
script(src="/js/bundler.js")
11+
script(src="/js/bundle.js")

source/js/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import React from "react"
2-
import Router from "react-router"
2+
import {Router} from "react-router"
33

44
import {Component} from "platform/react"
55
import Header from "components/header"
66

7-
const RouteHandler = Router.RouteHandler
8-
97
export default class App extends Component {
108
render() {
119
return(
1210
<div>
1311
<Header />
14-
<RouteHandler/>
12+
{this.props.children}
1513
</div>
1614
)
1715
}

source/js/main.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// for React Routing
22
import React from "react"
33
import ReactDOM from "react-dom"
4-
import Router from "react-router"
4+
import {Router, hashHistory} from "react-router"
55
import Routes from "routes"
66

7-
Router.run(Routes, function(Handler, state) {
8-
ReactDOM.render(<Handler />, document.getElementById('app'))
9-
})
7+
ReactDOM.render(
8+
<Router history={hashHistory}>{Routes}</Router>,
9+
document.getElementById('app')
10+
)

source/js/platform/react-flux.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Ajax} from "platform/plain"
44

55
import Dispatcher from "dispatcher/dispatcher"
66
import EventTypes from "constants/event"
7+
import EventEmitter from "wolfy87-eventemitter"
78

89
// array to object[key: key]
910
export function KeyMirror(arrays) {

source/js/platform/react-ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class Text extends Input {
8181
let classRow = this.props.row ? 'l-row ' : ''
8282
let className = `form-control ${classRow}${this.props.className}`
8383
let input = (
84-
<input type='text' id={this.props.id} className={className} placeholder={this.props.placeholder} maxsize={this.props.maxsize} value={this.state.value} onChange={this.onChange.bind(this)} />
84+
<input type='text' id={this.props.id} className={className} placeholder={this.props.placeholder} value={this.state.value || ""} onChange={this.onChange.bind(this)} />
8585
)
8686
let message = this.error()
8787
if (message) {

source/js/platform/react.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from "react"
22
import ReactDOM from "react-dom"
3-
import Router from "react-router"
3+
import {Router, Link, Navigation} from "react-router"
44
import ReactMixin from 'react-mixin'
55

66
import Param from "variables"
77
import {Ajax} from "platform/plain"
88
import * as ReactUI from "platform/react-ui"
99

1010
export class Component extends React.Component {
11-
constructor(props) {
12-
super(props)
11+
constructor(props, context) {
12+
super(props, context)
1313
let state = {
1414
message: {}
1515
}
@@ -19,11 +19,11 @@ export class Component extends React.Component {
1919
this.initialize()
2020
}
2121
static router() { return Router }
22-
static routerLink() { return this.router().Link }
22+
static routerLink() { return Link }
2323
initState() { return {} }
2424
initialize() { /* nothing. */ }
2525
forward(path) {
26-
this.transitionTo(path)
26+
this.context.router.transitionTo(path)
2727
}
2828
updateState(data) {
2929
if (!this.mounted) return
@@ -91,4 +91,8 @@ export class Component extends React.Component {
9191
this.mounted = false
9292
}
9393
}
94-
ReactMixin.onClass(Component, Router.Navigation)
94+
ReactMixin.onClass(Component, Navigation)
95+
Component.contextTypes = {
96+
router: React.PropTypes.object
97+
}
98+

0 commit comments

Comments
 (0)