Skip to content

Commit 1bcd68b

Browse files
committed
a interviewTest rebuild by reactJS
1 parent 62975e3 commit 1bcd68b

Some content is hidden

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

45 files changed

+1032
-0
lines changed

.babelrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"stage-0",
5+
"react"
6+
]
7+
}

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.eslintrc

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": [
4+
"react"
5+
],
6+
"parserOptions": {
7+
"ecmaVersion": 6,
8+
"sourceType": "module",
9+
"ecmaFeatures": {
10+
"jsx": true
11+
}
12+
},
13+
"env": {
14+
"browser": true,
15+
"amd": true,
16+
"es6": true,
17+
"node": true,
18+
"mocha": true
19+
},
20+
"rules": {
21+
"comma-dangle": 1,
22+
"no-undef": 0,
23+
"global-strict": 0,
24+
"no-extra-semi": 1,
25+
"no-underscore-dangle": 0,
26+
"no-console": 0,
27+
"no-unused-vars": 0,
28+
"no-trailing-spaces": [1, { "skipBlankLines": true }],
29+
"no-unreachable": 1,
30+
"no-alert": 0,
31+
"react/jsx-uses-react": 1,
32+
"react/jsx-uses-vars": 1
33+
}
34+
}

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules
28+
29+
# Bower
30+
bower_components/
31+
32+
# IDE/Editor data
33+
.idea

.yo-rc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"generator-react-webpack": {}
3+
}

cfg/base.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use strict';
2+
let path = require('path');
3+
let defaultSettings = require('./defaults');
4+
5+
// Additional npm or bower modules to include in builds
6+
// Add all foreign plugins you may need into this array
7+
// @example:
8+
// let npmBase = path.join(__dirname, '../node_modules');
9+
// let additionalPaths = [ path.join(npmBase, 'react-bootstrap') ];
10+
let additionalPaths = [];
11+
12+
module.exports = {
13+
additionalPaths: additionalPaths,
14+
port: defaultSettings.port,
15+
debug: true,
16+
devtool: 'eval',
17+
output: {
18+
path: path.join(__dirname, '/../dist/assets'),
19+
filename: 'app.js',
20+
publicPath: defaultSettings.publicPath
21+
},
22+
devServer: {
23+
contentBase: './src/',
24+
historyApiFallback: true,
25+
hot: true,
26+
port: defaultSettings.port,
27+
publicPath: defaultSettings.publicPath,
28+
noInfo: false,
29+
proxy: {
30+
'/feed': {
31+
target: 'http://36kr.com/',
32+
changeOrigin: true,
33+
secure: false
34+
}
35+
}
36+
},
37+
resolve: {
38+
extensions: ['', '.js', '.jsx','.styl','.less'],
39+
alias: {
40+
actions: `${defaultSettings.srcPath}/actions/`,
41+
components: `${defaultSettings.srcPath}/components/`,
42+
sources: `${defaultSettings.srcPath}/sources/`,
43+
stores: `${defaultSettings.srcPath}/stores/`,
44+
styles: `${defaultSettings.srcPath}/styles/`,
45+
config: `${defaultSettings.srcPath}/config/` + process.env.REACT_WEBPACK_ENV,
46+
'react/lib/ReactMount': 'react-dom/lib/ReactMount'
47+
}
48+
},
49+
module: {}
50+
};

cfg/defaults.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Function that returns default values.
3+
* Used because Object.assign does a shallow instead of a deep copy.
4+
* Using [].push will add to the base array, so a require will alter
5+
* the base array output.
6+
*/
7+
'use strict';
8+
9+
const path = require('path');
10+
const srcPath = path.join(__dirname, '/../src');
11+
const dfltPort = 8080;
12+
13+
/**
14+
* Get the default modules object for webpack
15+
* @return {Object}
16+
*/
17+
function getDefaultModules() {
18+
return {
19+
preLoaders: [
20+
{
21+
test: /\.(js|jsx)$/,
22+
include: srcPath,
23+
loader: 'eslint-loader'
24+
}
25+
],
26+
loaders: [
27+
{
28+
test: /\.css$/,
29+
loader: 'style-loader!css-loader'
30+
},
31+
{
32+
test: /\.sass/,
33+
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
34+
},
35+
{
36+
test: /\.scss/,
37+
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded'
38+
},
39+
{
40+
test: /\.less/,
41+
loader: 'style-loader!css-loader!less-loader'
42+
},
43+
{
44+
test: /\.styl/,
45+
loader: 'style-loader!css-loader!stylus-loader'
46+
},
47+
{
48+
test: /\.(png|jpg|gif|woff|woff2)$/,
49+
loader: 'url-loader?limit=8192'
50+
},
51+
{
52+
test: /\.(mp4|ogg|svg)$/,
53+
loader: 'file-loader'
54+
}
55+
]
56+
};
57+
}
58+
59+
module.exports = {
60+
srcPath: srcPath,
61+
publicPath: '/assets/',
62+
port: dfltPort,
63+
getDefaultModules: getDefaultModules
64+
};

cfg/dev.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use strict';
2+
3+
let path = require('path');
4+
let webpack = require('webpack');
5+
let baseConfig = require('./base');
6+
let defaultSettings = require('./defaults');
7+
8+
// Add needed plugins here
9+
let BowerWebpackPlugin = require('bower-webpack-plugin');
10+
11+
let config = Object.assign({}, baseConfig, {
12+
entry: [
13+
'webpack-dev-server/client?http://127.0.0.1:' + defaultSettings.port,
14+
'webpack/hot/only-dev-server',
15+
'./src/index'
16+
],
17+
cache: true,
18+
devtool: 'eval-source-map',
19+
plugins: [
20+
new webpack.HotModuleReplacementPlugin(),
21+
new webpack.NoErrorsPlugin(),
22+
new BowerWebpackPlugin({
23+
searchResolveModulesDirectories: false
24+
})
25+
],
26+
module: defaultSettings.getDefaultModules()
27+
});
28+
29+
// Add needed loaders to the defaults here
30+
config.module.loaders.push({
31+
test: /\.(js|jsx)$/,
32+
loader: 'react-hot!babel-loader',
33+
include: [].concat(
34+
config.additionalPaths,
35+
[ path.join(__dirname, '/../src') ]
36+
)
37+
});
38+
39+
module.exports = config;

cfg/dist.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
let path = require('path');
4+
let webpack = require('webpack');
5+
6+
let baseConfig = require('./base');
7+
let defaultSettings = require('./defaults');
8+
9+
// Add needed plugins here
10+
let BowerWebpackPlugin = require('bower-webpack-plugin');
11+
12+
let config = Object.assign({}, baseConfig, {
13+
entry: path.join(__dirname, '../src/index'),
14+
cache: false,
15+
devtool: 'sourcemap',
16+
plugins: [
17+
new webpack.optimize.DedupePlugin(),
18+
new webpack.DefinePlugin({
19+
'process.env.NODE_ENV': '"production"'
20+
}),
21+
new BowerWebpackPlugin({
22+
searchResolveModulesDirectories: false
23+
}),
24+
new webpack.optimize.UglifyJsPlugin(),
25+
new webpack.optimize.OccurenceOrderPlugin(),
26+
new webpack.optimize.AggressiveMergingPlugin(),
27+
new webpack.NoErrorsPlugin()
28+
],
29+
module: defaultSettings.getDefaultModules()
30+
});
31+
32+
// Add needed loaders to the defaults here
33+
config.module.loaders.push({
34+
test: /\.(js|jsx)$/,
35+
loader: 'babel',
36+
include: [].concat(
37+
config.additionalPaths,
38+
[ path.join(__dirname, '/../src') ]
39+
)
40+
});
41+
42+
module.exports = config;

cfg/test.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict';
2+
3+
let path = require('path');
4+
let srcPath = path.join(__dirname, '/../src/');
5+
6+
let baseConfig = require('./base');
7+
8+
// Add needed plugins here
9+
let BowerWebpackPlugin = require('bower-webpack-plugin');
10+
11+
module.exports = {
12+
devtool: 'eval',
13+
module: {
14+
preLoaders: [
15+
{
16+
test: /\.(js|jsx)$/,
17+
loader: 'isparta-instrumenter-loader',
18+
include: [
19+
path.join(__dirname, '/../src')
20+
]
21+
}
22+
],
23+
loaders: [
24+
{
25+
test: /\.(png|jpg|gif|woff|woff2|css|sass|scss|less|styl)$/,
26+
loader: 'null-loader'
27+
},
28+
{
29+
test: /\.(js|jsx)$/,
30+
loader: 'babel-loader',
31+
include: [].concat(
32+
baseConfig.additionalPaths,
33+
[
34+
path.join(__dirname, '/../src'),
35+
path.join(__dirname, '/../test')
36+
]
37+
)
38+
}
39+
]
40+
},
41+
resolve: {
42+
extensions: [ '', '.js', '.jsx' ],
43+
alias: {
44+
actions: srcPath + 'actions/',
45+
helpers: path.join(__dirname, '/../test/helpers'),
46+
components: srcPath + 'components/',
47+
sources: srcPath + 'sources/',
48+
stores: srcPath + 'stores/',
49+
styles: srcPath + 'styles/',
50+
config: srcPath + 'config/' + process.env.REACT_WEBPACK_ENV
51+
}
52+
},
53+
plugins: [
54+
new BowerWebpackPlugin({
55+
searchResolveModulesDirectories: false
56+
})
57+
]
58+
};

dist/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# About the dist folder
2+
After building the dist version of your project, the generated files are stored in this folder. You should keep it under version control.

dist/assets/app.js

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assets/app.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/favicon.ico

4.19 KB
Binary file not shown.

dist/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>React Webpack Template Title</title>
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
9+
</head>
10+
<body>
11+
<div id="app">loading...</div>
12+
13+
<script>__REACT_DEVTOOLS_GLOBAL_HOOK__ = parent.__REACT_DEVTOOLS_GLOBAL_HOOK__</script>
14+
<script type="text/javascript" src="/assets/app.js"></script>
15+
</body>
16+
</html>

dist/static/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# static
2+
3+
Files and directories that you put in `static` will be copied to the
4+
`dist/static` directory during the build step. Use it to provide
5+
arbitrary static assets that can be referenced by path in your
6+
application.

dist/static/favicon.ico

4.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)