Skip to content

Commit 3b1eb1a

Browse files
committed
setup all done
1 parent b443862 commit 3b1eb1a

Some content is hidden

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

66 files changed

+4146
-0
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,35 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
# See https://help.github.com/ignore-files/ for more about ignoring files.
106+
107+
# dependencies
108+
/node_modules
109+
110+
# testing
111+
/coverage
112+
113+
# production
114+
/build
115+
116+
# misc
117+
.DS_Store
118+
.env
119+
npm-debug.log*
120+
yarn-debug.log*
121+
yarn-error.log*
122+
123+
# built component library
124+
/lib
125+
126+
# built docs
127+
/docs
128+
129+
# Generated component data
130+
/config/componentData.js
131+
132+
# VSCode launch configuration
133+
launch.json
134+
135+
# Webstorm
136+
.idea

README.md

Lines changed: 1623 additions & 0 deletions
Large diffs are not rendered by default.

config/env.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
4+
// injected into the application via DefinePlugin in Webpack configuration.
5+
6+
var REACT_APP = /^REACT_APP_/i;
7+
8+
function getClientEnvironment(publicUrl) {
9+
var raw = Object
10+
.keys(process.env)
11+
.filter(key => REACT_APP.test(key))
12+
.reduce((env, key) => {
13+
env[key] = process.env[key];
14+
return env;
15+
}, {
16+
// Useful for determining whether we’re running in production mode.
17+
// Most importantly, it switches React into the correct mode.
18+
'NODE_ENV': process.env.NODE_ENV || 'development',
19+
// Useful for resolving the correct path to static assets in `public`.
20+
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
21+
// This should only be used as an escape hatch. Normally you would put
22+
// images into the `src` and `import` them in code to get their paths.
23+
'PUBLIC_URL': publicUrl
24+
});
25+
// Stringify all values so we can feed into Webpack DefinePlugin
26+
var stringified = {
27+
'process.env': Object
28+
.keys(raw)
29+
.reduce((env, key) => {
30+
env[key] = JSON.stringify(raw[key]);
31+
return env;
32+
}, {})
33+
};
34+
35+
return { raw, stringified };
36+
}
37+
38+
module.exports = getClientEnvironment;

config/jest/cssTransform.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
// This is a custom Jest transformer turning style imports into empty objects.
4+
// http://facebook.github.io/jest/docs/tutorial-webpack.html
5+
6+
module.exports = {
7+
process() {
8+
return 'module.exports = {};';
9+
},
10+
getCacheKey() {
11+
// The output is always the same.
12+
return 'cssTransform';
13+
},
14+
};

config/jest/fileTransform.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
5+
// This is a custom Jest transformer turning file imports into filenames.
6+
// http://facebook.github.io/jest/docs/tutorial-webpack.html
7+
8+
module.exports = {
9+
process(src, filename) {
10+
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
11+
},
12+
};

config/paths.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
'use strict';
2+
3+
var path = require('path');
4+
var fs = require('fs');
5+
var url = require('url');
6+
7+
// Make sure any symlinks in the project folder are resolved:
8+
// https://github.com/facebookincubator/create-react-app/issues/637
9+
var appDirectory = fs.realpathSync(process.cwd());
10+
function resolveApp(relativePath) {
11+
return path.resolve(appDirectory, relativePath);
12+
}
13+
14+
// We support resolving modules according to `NODE_PATH`.
15+
// This lets you use absolute paths in imports inside large monorepos:
16+
// https://github.com/facebookincubator/create-react-app/issues/253.
17+
18+
// It works similar to `NODE_PATH` in Node itself:
19+
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
20+
21+
// We will export `nodePaths` as an array of absolute paths.
22+
// It will then be used by Webpack configs.
23+
// Jest doesn’t need this because it already handles `NODE_PATH` out of the box.
24+
25+
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
26+
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
27+
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
28+
29+
var nodePaths = (process.env.NODE_PATH || '')
30+
.split(process.platform === 'win32' ? ';' : ':')
31+
.filter(Boolean)
32+
.filter(folder => !path.isAbsolute(folder))
33+
.map(resolveApp);
34+
35+
var envPublicUrl = process.env.PUBLIC_URL;
36+
37+
function ensureSlash(path, needsSlash) {
38+
var hasSlash = path.endsWith('/');
39+
if (hasSlash && !needsSlash) {
40+
return path.substr(path, path.length - 1);
41+
} else if (!hasSlash && needsSlash) {
42+
return path + '/';
43+
} else {
44+
return path;
45+
}
46+
}
47+
48+
function getPublicUrl(appPackageJson) {
49+
return envPublicUrl || require(appPackageJson).homepage;
50+
}
51+
52+
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
53+
// "public path" at which the app is served.
54+
// Webpack needs to know it to put the right <script> hrefs into HTML even in
55+
// single-page apps that may serve index.html for nested URLs like /todos/42.
56+
// We can't use a relative path in HTML because we don't want to load something
57+
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
58+
function getServedPath(appPackageJson) {
59+
var publicUrl = getPublicUrl(appPackageJson);
60+
var servedUrl = envPublicUrl || (
61+
publicUrl ? url.parse(publicUrl).pathname : '/'
62+
);
63+
return ensureSlash(servedUrl, true);
64+
}
65+
66+
// config after eject: we're in ./config/
67+
module.exports = {
68+
appBuild: resolveApp('build'),
69+
appPublic: resolveApp('public'),
70+
appHtml: resolveApp('public/index.html'),
71+
appIndexJs: resolveApp('src/index.js'),
72+
appPackageJson: resolveApp('package.json'),
73+
appSrc: resolveApp('src'),
74+
yarnLockFile: resolveApp('yarn.lock'),
75+
testsSetup: resolveApp('src/setupTests.js'),
76+
appNodeModules: resolveApp('node_modules'),
77+
nodePaths: nodePaths,
78+
publicUrl: getPublicUrl(resolveApp('package.json')),
79+
servedPath: getServedPath(resolveApp('package.json'))
80+
};

config/polyfills.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
if (typeof Promise === 'undefined') {
4+
// Rejection tracking prevents a common issue where React gets into an
5+
// inconsistent state due to an error, but it gets swallowed by a Promise,
6+
// and the user has no idea what causes React's erratic future behavior.
7+
require('promise/lib/rejection-tracking').enable();
8+
window.Promise = require('promise/lib/es6-extensions.js');
9+
}
10+
11+
// fetch() polyfill for making API calls.
12+
require('whatwg-fetch');
13+
14+
// Object.assign() is commonly used with React.
15+
// It will use the native implementation if it's present and isn't buggy.
16+
Object.assign = require('object-assign');

0 commit comments

Comments
 (0)