Skip to content

Commit 2c18f73

Browse files
authored
Merge pull request #5 from monkeyInShell/dev
Dev
2 parents 896c2c4 + dad743e commit 2c18f73

File tree

37 files changed

+80
-16
lines changed

37 files changed

+80
-16
lines changed

.babelrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"presets": [["env", {
2+
"presets": [
3+
["env", {
34
"targets": {
45
"browsers": ["last 2 versions", "safari >= 7"],
56
"node": "8.9.3"
67
}
78
}], "react"],
89
"plugins": [
910
"transform-class-properties", //解析类属性,静态和实例的属性
10-
"syntax-dynamic-import"//不解析动态加载标识符 import()
11+
"syntax-dynamic-import"//不解析动态加载标识符 import() node环境无作用,得另想办法
1112
],
1213
"env": {
1314
"node": {
@@ -16,7 +17,7 @@
1617
{
1718
"extensions": [".less", ".sass"]
1819
}
19-
]]
20+
], "dynamic-import-node"]
2021
}
2122
}
2223
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
## for production
55
> npm run build
66
### start production server
7+
78
> node bin/www.js

bin/www.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
* Created by ink on 2018/3/31.
33
*/
44
if (process.env.NODE_ENV === 'local') {
5+
//node运行时生效,同样也会去读.babelrc,plugins不会覆盖,会concat生效
6+
//webpack生效的配置是.babelrc
57
require('babel-register')({
68
'plugins': [
79
[
810
'babel-plugin-transform-require-ignore',
911
{
1012
extensions: ['.less']
1113
}
12-
]
14+
],
15+
'dynamic-import-node'
1316
]
1417
})
1518
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

client/pages/example/Dashboard/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import Hoc from '../hoc/Hoc';
6-
import Dashboard from '../../../components/Dashboard';
6+
import Dashboard from '../../../Components/Dashboard';
77
import './index.less';
88
class Index extends Hoc {
99
constructor (options) {

client/pages/example/ImgUpload/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import Hoc from '../hoc/Hoc';
6-
import ImgUpload from '../../../components/ImgUpload';
6+
import ImgUpload from '../../../Components/ImgUpload';
77
import './index.less';
88
class Index extends Hoc {
99
constructor (options) {

client/pages/example/ItemMove/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import './index.less';
6-
import ItemMove from '../../../components/ItemMove';
6+
import ItemMove from '../../../Components/ItemMove';
77
import Hoc from '../hoc/Hoc';
88
class Index extends Hoc {
99
constructor (options) {

client/pages/example/PullRefresh/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import Hoc from '../hoc/Hoc';
6-
import PullRefresh from '../../../components/PullRefresh';
6+
import PullRefresh from '../../../Components/PullRefresh';
77
import './index.less';
88
class Index extends Hoc {
99
constructor (options) {

client/pages/example/Slide/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Created by zhouyunkui on 2017/6/9.
33
*/
44
import React from 'react';
5-
import {Slide, SlideItem, } from '../../../components/Slide';
5+
import {Slide, SlideItem, } from '../../../Components/Slide';
66
import Hoc from '../hoc/Hoc';
77
import './index.less';
88
class Index extends Hoc {

client/pages/example/Staff/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React from 'react'
55
import './index.less'
66
import Hoc from '../hoc/Hoc'
7-
import Staff from '../../../components/Staff'
7+
import Staff from '../../../Components/Staff'
88
class Index extends Hoc {
99
constructor (options) {
1010
super(options)

client/pages/example/UploadMore/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React from 'react'
55
import Hoc from '../hoc/Hoc'
66
import './index.less'
7-
import UploadMore from '../../../components/UploadMore'
7+
import UploadMore from '../../../Components/UploadMore'
88
class Index extends Hoc {
99
constructor (options) {
1010
super(options)

client/pages/integration/App.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
* Created by ink on 2018/4/8.
33
*/
44
import React, {Fragment} from 'react'
5-
import Center from './Center'
6-
import Home from './Home'
5+
import Loading from './Components/Loading'
76
import {Switch, Route, Link} from 'react-router-dom'
8-
7+
import load from '../tools/lazyLoad/'
8+
const lazyLoad = load('integration/', Loading)
9+
const Home = lazyLoad('Home')
10+
const Center = lazyLoad('Center')
911
const App = (props) => {
1012
return (
1113
<Fragment>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Created by ink on 2018/4/11.
3+
*/
4+
import React from 'react'
5+
function Loading(props) {
6+
let content = ''
7+
if (props.error) {
8+
content = props.error
9+
} else if (props.timedOut) {
10+
content = '加载超时'
11+
} else if (props.pastDelay) {
12+
content = '加载中...'
13+
} else {
14+
content = '加载中...'
15+
}
16+
return <div>{content}</div>
17+
}
18+
export default Loading

client/pages/tools/lazyLoad/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Created by ink on 2018/4/11.
3+
*/
4+
import React from 'react'
5+
import Loadable from 'react-loadable'
6+
const loadingComponent = Loading => props => {
7+
//props.error:When the loader has errored
8+
//props.timedOut: When the loader has taken longer than the timeout
9+
//props.pastDelay: When the loader has taken longer than the delay
10+
//else: When the loader has just started
11+
return <Loading {...props}/>
12+
}
13+
export default (prefix, Loading) => path => {
14+
return Loadable({
15+
loader: () => import(`../../${prefix}${path}`),
16+
loading: loadingComponent(Loading),
17+
timeout: 10000
18+
})
19+
}

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"babel-cli": "^6.26.0",
1414
"babel-eslint": "^8.2.2",
1515
"babel-loader": "^7.1.4",
16+
"babel-plugin-dynamic-import-node": "^1.2.0",
1617
"babel-plugin-syntax-dynamic-import": "^6.18.0",
1718
"babel-plugin-transform-class-properties": "^6.24.1",
1819
"babel-plugin-transform-require-ignore": "^0.1.1",
@@ -36,6 +37,7 @@
3637
"less-loader": "^4.1.0",
3738
"react": "^16.2.0",
3839
"react-dom": "^16.2.0",
40+
"react-loadable": "^5.3.1",
3941
"react-redux": "^5.0.7",
4042
"react-router": "^4.2.0",
4143
"react-router-dom": "^4.2.2",

server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (process.env.NODE_ENV === 'local') {
4040
}
4141

4242
//以路径名称作为页面区分
43-
app.use('/components', extractMapping, (req, res, next) => {
43+
app.use('/Components', extractMapping, (req, res, next) => {
4444
//可以根据路径,针对某一个页面进行服务端渲染
4545
const content = renderToString(<StaticRouter
4646
location={req.url}

webpack.config.pro.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const path = require('path')
55
const webpack = require('webpack')
66
const contentPath = path.resolve(__dirname, 'dist/public/mapping')
7+
//extract-text-webpack-plugin 还是beta版有bug,不同入口的css内容都一样
78
const ExtractCssChunks = require('extract-text-webpack-plugin')
89
const publicPath = '/mapping/'
910
const commonConfig = require('./webpack.config.common')
@@ -31,7 +32,8 @@ const config = {
3132
'process.env.NODE_ENV': JSON.stringify('production')
3233
}),
3334
new ExtractCssChunks({
34-
filename: '[name].[id].css'
35+
filename: '[name].[id].css',
36+
allChunks: true
3537
}),
3638
...commonConfig.plugins
3739
]

0 commit comments

Comments
 (0)