Skip to content

Commit 0c4d5b4

Browse files
author
kenberkeley
committed
add preview
1 parent 21dc72d commit 0c4d5b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+12483
-1
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# React 示例项目 · 简易留言板
22

3-
> ### 好消息:本项目将采用 `vue-cli` 生成的模板重构,敬请期待(建议 watch)!
3+
> ### (2016/8/24) 好消息:本项目将采用 `vue-cli` 生成的模板重构,敬请期待(建议 watch)!
44
> ### 实在难以忍受那些拥有复杂架构的 React 示例项目!我们要向 Vue 看齐!!!
55
6+
***
7+
8+
> ### (2016/8/25) 好消息:预览版的 React Demo by vue-cli 已经放到了
9+
> ### `基于Vue_Demo的React_Demo预览版在此!` 目录
10+
> ### 注释齐全,与 [Vue Demo][vue-demo] 高度一致,启动方式也一致,欢迎预览!
11+
> ### 当前正在完善 README 文档,敬请期待!
12+
613
![应用截图](./screenshot.png)
714

815
> ###写在前面
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": ["es2015", "react", "stage-0"],
3+
"plugins": ["transform-runtime"],
4+
"comments": false
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/**
2+
node_modules/**
3+
src/assets/**
4+
static/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"jquery": true
7+
},
8+
"plugins": [
9+
"react"
10+
],
11+
"globals": {
12+
"__DEV__": true,
13+
"__PROD__": true,
14+
"__COMPONENT_DEVTOOLS__": false
15+
},
16+
"ecmaFeatures": {
17+
"jsx": true,
18+
"arrowFunctions": true,
19+
"destructuring": true,
20+
"classes": true,
21+
"defaultParams": true,
22+
"blockBindings": true,
23+
"modules": true,
24+
"objectLiteralComputedProperties": true,
25+
"objectLiteralShorthandMethods": true,
26+
"objectLiteralShorthandProperties": true,
27+
"restParams": true,
28+
"spread": true,
29+
"forOf": true,
30+
"generators": true,
31+
"templateStrings": true,
32+
"superInFunctions": true,
33+
"experimentalObjectRestSpread": true
34+
},
35+
"rules": {
36+
"accessor-pairs": 2,
37+
"array-bracket-spacing": 0,
38+
"block-scoped-var": 0,
39+
"brace-style": [0, "allman", { "allowSingleLine": true }],
40+
"camelcase": 1,
41+
"comma-dangle": [2, "never"],
42+
"comma-spacing": [2, { "before": false, "after": true }],
43+
"comma-style": [2, "last"],
44+
"complexity": 0,
45+
"computed-property-spacing": 0,
46+
"consistent-return": 0,
47+
"consistent-this": 0,
48+
"constructor-super": 2,
49+
"curly": [0, "multi-line"],
50+
"default-case": 0,
51+
"dot-location": [2, "property"],
52+
"dot-notation": 0,
53+
"eol-last": 2,
54+
"eqeqeq": 0,
55+
"func-names": 0,
56+
"func-style": 0,
57+
"generator-star-spacing": [2, { "before": true, "after": true }],
58+
"guard-for-in": 0,
59+
"handle-callback-err": [2, "^(err|error)$" ],
60+
"indent": 0,
61+
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
62+
"linebreak-style": 0,
63+
"lines-around-comment": 0,
64+
"max-nested-callbacks": 0,
65+
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
66+
"new-parens": 2,
67+
"newline-after-var": 0,
68+
"no-alert": 0,
69+
"no-array-constructor": 2,
70+
"no-caller": 2,
71+
"no-catch-shadow": 0,
72+
"no-cond-assign": 2,
73+
"no-console": 0,
74+
"no-constant-condition": 0,
75+
"no-continue": 0,
76+
"no-control-regex": 2,
77+
"no-debugger": 2,
78+
"no-delete-var": 2,
79+
"no-div-regex": 0,
80+
"no-dupe-args": 2,
81+
"no-dupe-keys": 2,
82+
"no-duplicate-case": 2,
83+
"no-else-return": 0,
84+
"no-empty": 0,
85+
"no-empty-character-class": 2,
86+
"no-empty-label": 2,
87+
"no-eq-null": 0,
88+
"no-eval": 2,
89+
"no-ex-assign": 2,
90+
"no-extend-native": 2,
91+
"no-extra-bind": 2,
92+
"no-extra-boolean-cast": 2,
93+
"no-extra-parens": 0,
94+
"no-extra-semi": 0,
95+
"no-fallthrough": 2,
96+
"no-floating-decimal": 2,
97+
"no-func-assign": 2,
98+
"no-implied-eval": 2,
99+
"no-inline-comments": 0,
100+
"no-inner-declarations": [2, "functions"],
101+
"no-invalid-regexp": 2,
102+
"no-irregular-whitespace": 2,
103+
"no-iterator": 2,
104+
"no-label-var": 2,
105+
"no-labels": 2,
106+
"no-lone-blocks": 2,
107+
"no-lonely-if": 0,
108+
"no-loop-func": 0,
109+
"no-mixed-requires": 0,
110+
"no-mixed-spaces-and-tabs": 2,
111+
"no-multi-spaces": 2,
112+
"no-multi-str": 2,
113+
"no-multiple-empty-lines": [0, { "max": 1 }],
114+
"no-native-reassign": 2,
115+
"no-negated-in-lhs": 2,
116+
"no-nested-ternary": 0,
117+
"no-new": 2,
118+
"no-new-func": 0,
119+
"no-new-object": 2,
120+
"no-new-require": 2,
121+
"no-new-wrappers": 2,
122+
"no-obj-calls": 2,
123+
"no-octal": 2,
124+
"no-octal-escape": 2,
125+
"no-param-reassign": 0,
126+
"no-path-concat": 0,
127+
"no-process-env": 0,
128+
"no-process-exit": 0,
129+
"no-proto": 0,
130+
"no-redeclare": 2,
131+
"no-regex-spaces": 2,
132+
"no-restricted-modules": 0,
133+
"no-return-assign": 2,
134+
"no-script-url": 0,
135+
"no-self-compare": 2,
136+
"no-sequences": 2,
137+
"no-shadow": 0,
138+
"no-shadow-restricted-names": 2,
139+
"no-spaced-func": 2,
140+
"no-sparse-arrays": 2,
141+
"no-sync": 0,
142+
"no-ternary": 0,
143+
"no-this-before-super": 2,
144+
"no-throw-literal": 2,
145+
"no-trailing-spaces": 0,
146+
"no-undef": 2,
147+
"no-undef-init": 2,
148+
"no-undefined": 0,
149+
"no-underscore-dangle": 0,
150+
"no-unexpected-multiline": 2,
151+
"no-unneeded-ternary": 2,
152+
"no-unreachable": 2,
153+
"no-unused-expressions": 0,
154+
"no-unused-vars": [2, { "vars": "all", "varsIgnorePattern": "React", "args": "none" }],
155+
"no-use-before-define": 0,
156+
"no-var": 0,
157+
"no-void": 0,
158+
"no-warning-comments": 0,
159+
"no-with": 2,
160+
"object-curly-spacing": 0,
161+
"object-shorthand": 0,
162+
"one-var": [2, { "initialized": "never" }],
163+
"operator-assignment": 0,
164+
"operator-linebreak": 0,
165+
"padded-blocks": 0,
166+
"prefer-const": 0,
167+
"quote-props": 0,
168+
"quotes": [2, "single", "avoid-escape"],
169+
"radix": 2,
170+
"react/jsx-uses-react": 2,
171+
"react/jsx-uses-vars": 2,
172+
"semi": [2, "never"],
173+
"semi-spacing": 0,
174+
"sort-vars": 0,
175+
"space-after-keywords": [2, "always"],
176+
"space-before-blocks": [2, "always"],
177+
"space-before-function-paren": 0,
178+
"space-in-parens": [2, "never"],
179+
"space-infix-ops": 2,
180+
"space-return-throw-case": 2,
181+
"space-unary-ops": [2, { "words": true, "nonwords": false }],
182+
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!"] }],
183+
"strict": 0,
184+
"use-isnan": 2,
185+
"valid-jsdoc": 0,
186+
"valid-typeof": 2,
187+
"vars-on-top": 0,
188+
"wrap-iife": [2, "any"],
189+
"wrap-regex": 0,
190+
"yoda": [2, "never"]
191+
}
192+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
*.log
3+
coverage
4+
dist
5+
node_modules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> README 正在完善中
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var path = require('path'),
2+
express = require('express'),
3+
webpack = require('webpack'),
4+
// favicon = require('express-favicon'),
5+
config = require('./webpack.dev.conf'),
6+
app = express();
7+
8+
var compiler = webpack(config);
9+
10+
// for highly stable resources
11+
app.use('/static', express.static(path.join(__dirname, '../static')));
12+
13+
// app.use(favicon(path.join(__dirname, '../favicon.ico')));
14+
15+
// handle fallback for HTML5 history API
16+
app.use(require('connect-history-api-fallback')());
17+
18+
// serve webpack bundle output
19+
app.use(require('webpack-dev-middleware')(compiler, {
20+
noInfo: true,
21+
publicPath: config.output.publicPath
22+
}));
23+
24+
// enable hot-reload and state-preserving
25+
// compilation error display
26+
app.use(require('webpack-hot-middleware')(compiler));
27+
28+
app.listen(9000, '127.0.0.1', function(err) {
29+
if (err) {
30+
console.log(err);
31+
return;
32+
}
33+
console.log('Listening at http://127.0.0.1:9000');
34+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
var path = require('path'),
2+
webpack = require('webpack');
3+
4+
var srcPath = path.resolve(__dirname, '../src');
5+
6+
module.exports = {
7+
entry: {
8+
app: path.join(srcPath, 'app.js'),
9+
10+
// ================================
11+
// 框架 / 类库 分离打包
12+
// ================================
13+
vendor: [
14+
'history',
15+
'lodash',
16+
'react',
17+
'react-dom',
18+
'react-redux',
19+
'react-router',
20+
'react-router-redux',
21+
'redux',
22+
'redux-thunk',
23+
'superagent'
24+
]
25+
},
26+
output: {
27+
path: path.resolve(__dirname, '../dist/static'),
28+
publicPath: '/static/'
29+
},
30+
resolve: {
31+
extensions: ['', '.js', '.jsx', '.json'],
32+
alias: {
33+
// ================================
34+
// 自定义路径别名
35+
// ================================
36+
COMPONENT: path.join(srcPath, 'components'),
37+
CONTAINER: path.join(srcPath, 'containers'),
38+
ACTION: path.join(srcPath, 'redux/actions'),
39+
REDUCER: path.join(srcPath, 'redux/reducers'),
40+
STORE: path.join(srcPath, 'redux/store'),
41+
ROUTE: path.join(srcPath, 'routes'),
42+
SERVICE: path.join(srcPath, 'services'),
43+
UTIL: path.join(srcPath, 'utils'),
44+
HOC: path.join(srcPath, 'utils/HOC'),
45+
MIXIN: path.join(srcPath, 'utils/mixins'),
46+
VIEW: path.join(srcPath, 'views')
47+
}
48+
},
49+
resolveLoader: {
50+
root: path.join(__dirname, 'node_modules')
51+
},
52+
module: {
53+
loaders: [{
54+
test: /\.(js|jsx)$/,
55+
include: srcPath,
56+
loaders: ['react-hot', 'babel?' + JSON.stringify({
57+
cacheDirectory: true,
58+
plugins: ['transform-runtime'],
59+
presets: ['es2015', 'react', 'stage-0'],
60+
env: {
61+
production: {
62+
presets: ['react-optimize']
63+
}
64+
}
65+
}), 'eslint']
66+
}, {
67+
test: /\.json$/,
68+
loader: 'json'
69+
}, {
70+
test: /\.less$/,
71+
loader: 'css!less'
72+
}, {
73+
test: /\.(png|jpg|gif|svg)$/,
74+
loader: 'url',
75+
query: {
76+
limit: 10000,
77+
name: '[name].[ext]?[hash]'
78+
}
79+
}, {
80+
test: /\.(eot|woff|ttf|svg)$/,
81+
loader: 'url-loader?limit=30000&name=[name]-[hash].[ext]'
82+
}]
83+
},
84+
eslint: {
85+
formatter: require('eslint-friendly-formatter')
86+
},
87+
plugins: [
88+
new webpack.optimize.CommonsChunkPlugin({
89+
names: ['vendor', 'mainifest']
90+
}),
91+
new webpack.DefinePlugin({
92+
// ================================
93+
// 配置开发全局常量
94+
// ================================
95+
__DEV__: process.env.NODE_ENV === 'development',
96+
__PROD__: process.env.NODE_ENV === 'production',
97+
__COMPONENT_DEVTOOLS__: false // 是否使用组件形式的 Redux DevTools
98+
})
99+
]
100+
};

0 commit comments

Comments
 (0)