Skip to content

Commit d9d7b18

Browse files
author
Daniel Figueiredo
committed
Chore - Rebasing from latest 0.9.4 facebook
1 parent a235694 commit d9d7b18

26 files changed

+670
-321
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ npm-debug.log*
1111
yarn-debug.log*
1212
yarn-error.log*
1313
/.changelog
14+
.idea/

README.md

+74-222
Large diffs are not rendered by default.

packages/react-scripts/config/paths.js

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ module.exports = {
8686
nodePaths: nodePaths,
8787
publicUrl: getPublicUrl(resolveApp('package.json')),
8888
servedPath: getServedPath(resolveApp('package.json')),
89+
testsCustomConfig: resolveApp('jest-config.json'),
90+
browsersFile: resolveApp('browsers.json'),
8991
};
9092

9193
// @remove-on-eject-begin
@@ -111,6 +113,8 @@ module.exports = {
111113
// These properties only exist before ejecting:
112114
ownPath: resolveOwn('.'),
113115
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
116+
testsCustomConfig: resolveApp('jest-config.json'),
117+
browsersFile: resolveApp('browsers.json'),
114118
};
115119

116120
const ownPackageJson = require('../package.json');
@@ -140,6 +144,8 @@ if (
140144
// These properties only exist before ejecting:
141145
ownPath: resolveOwn('.'),
142146
ownNodeModules: resolveOwn('node_modules'),
147+
testsCustomConfig: resolveApp('jest-config.json'),
148+
browsersFile: resolveApp('browsers.json'),
143149
};
144150
}
145151
// @remove-on-eject-end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const StyleLintPlugin = require('stylelint-webpack-plugin');
2+
3+
module.exports = [
4+
new StyleLintPlugin({
5+
configFile: './.stylelintrc',
6+
files: ['src/**/*.css'],
7+
failOnError: false,
8+
}),
9+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const webpack = require('webpack');
2+
const fs = require('fs');
3+
const paths = require('../paths');
4+
5+
const defaultBrowsers = {
6+
browsers: [
7+
'>1%',
8+
'last 4 versions',
9+
'Firefox ESR',
10+
'not ie < 9', // React doesn't support IE8 anyway
11+
]
12+
};
13+
14+
// Check if there is a browsers.json file and loads it if exists
15+
// this allows us to customize the browsers list without having to eject
16+
function loadBrowsersConfig() {
17+
return fs.existsSync(paths.browsersFile)
18+
? require(paths.browsersFile)
19+
: defaultBrowsers
20+
}
21+
22+
const postcssBasePlugins = [
23+
require('postcss-modules-local-by-default'),
24+
require('postcss-import')({
25+
addDependencyTo: webpack,
26+
}),
27+
require('postcss-cssnext')(loadBrowsersConfig()),
28+
];
29+
const postcssDevPlugins = [];
30+
const postcssProdPlugins = [
31+
require('cssnano')({
32+
safe: true,
33+
sourcemap: true,
34+
autoprefixer: false,
35+
}),
36+
];
37+
38+
const postcssPlugins = postcssBasePlugins
39+
.concat(process.env.NODE_ENV === 'production' ? postcssProdPlugins : [])
40+
.concat(process.env.NODE_ENV === 'development' ? postcssDevPlugins : []);
41+
42+
module.exports = () => {
43+
return postcssPlugins;
44+
};

packages/react-scripts/config/webpack.config.dev.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const publicUrl = '';
3434
// Get environment variables to inject into our app.
3535
const env = getClientEnvironment(publicUrl);
3636

37+
// Get postcss and cssnext config for webpack
38+
var postcss = require('./rangle/postcss');
39+
3740
// This is the development configuration.
3841
// It is focused on developer experience and fast rebuilds.
3942
// The production configuration is different and lives in a separate file.
@@ -201,16 +204,7 @@ module.exports = {
201204
loader: 'postcss-loader',
202205
options: {
203206
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
204-
plugins: () => [
205-
autoprefixer({
206-
browsers: [
207-
'>1%',
208-
'last 4 versions',
209-
'Firefox ESR',
210-
'not ie < 9', // React doesn't support IE8 anyway
211-
],
212-
}),
213-
],
207+
plugins: postcss,
214208
},
215209
},
216210
],
@@ -244,6 +238,9 @@ module.exports = {
244238
// makes the discovery automatic so you don't have to restart.
245239
// See https://github.com/facebookincubator/create-react-app/issues/186
246240
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
241+
242+
// rangle custom plugins such as stylelint
243+
...require('./rangle/plugins'),
247244
],
248245
// Some libraries import Node modules but don't use them in the browser.
249246
// Tell Webpack to provide empty mocks for them so importing them works.

packages/react-scripts/config/webpack.config.prod.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const publicUrl = publicPath.slice(0, -1);
3737
// Get environment variables to inject into our app.
3838
const env = getClientEnvironment(publicUrl);
3939

40+
// Get postcss and cssnext config for webpack
41+
var postcss = require('./rangle/postcss');
42+
4043
// Assert this just to be safe.
4144
// Development builds of React are slow and not intended for production.
4245
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
@@ -206,16 +209,7 @@ module.exports = {
206209
loader: 'postcss-loader',
207210
options: {
208211
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
209-
plugins: () => [
210-
autoprefixer({
211-
browsers: [
212-
'>1%',
213-
'last 4 versions',
214-
'Firefox ESR',
215-
'not ie < 9', // React doesn't support IE8 anyway
216-
],
217-
}),
218-
],
212+
plugins: postcss,
219213
},
220214
},
221215
],
@@ -283,6 +277,9 @@ module.exports = {
283277
new ManifestPlugin({
284278
fileName: 'asset-manifest.json',
285279
}),
280+
281+
// rangle custom plugins such as stylelint
282+
...require('./rangle/plugins'),
286283
],
287284
// Some libraries import Node modules but don't use them in the browser.
288285
// Tell Webpack to provide empty mocks for them so importing them works.

packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/logo.svg

-7
This file was deleted.

packages/react-scripts/package.json

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "react-scripts",
3-
"version": "0.9.4",
4-
"description": "Configuration and scripts for Create React App.",
5-
"repository": "facebookincubator/create-react-app",
2+
"name": "@rangle/react-scripts",
3+
"version": "0.0.9",
4+
"description": "Rangle's custom configuration and scripts for Create React App.",
5+
"repository": "rangle/create-react-app",
66
"license": "BSD-3-Clause",
77
"engines": {
88
"node": ">=4"
99
},
1010
"bugs": {
11-
"url": "https://github.com/facebookincubator/create-react-app/issues"
11+
"url": "https://github.com/rangle/rangle-starter/issues"
1212
},
1313
"files": [
1414
"babelrc",
@@ -51,10 +51,22 @@
5151
"http-proxy-middleware": "0.17.3",
5252
"jest": "18.1.0",
5353
"object-assign": "4.1.1",
54+
"postcss-cssnext": "^2.9.0",
55+
"postcss-import": "^9.0.0",
5456
"postcss-loader": "1.3.3",
57+
"postcss-modules-local-by-default": "^1.1.1",
5558
"promise": "7.1.1",
59+
"react": "^15.3.0",
5660
"react-dev-utils": "^0.5.2",
61+
"react-redux": "^5.0.1",
62+
"react-router": "^3.0.0",
63+
"react-router-redux": "^4.0.7",
64+
"redux": "^3.6.0",
65+
"redux-form": "^6.4.3",
66+
"stylelint": "^7.7.1",
67+
"stylelint-webpack-plugin": "^0.5.1",
5768
"style-loader": "0.13.2",
69+
"tachyons": "^4.6.1",
5870
"url-loader": "0.5.8",
5971
"webpack": "2.2.1",
6072
"webpack-dev-server": "2.4.1",

packages/react-scripts/scripts/eject.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ prompt(
4646
}
4747
}
4848

49-
const folders = ['config', 'config/jest', 'scripts', 'scripts/utils'];
49+
const folders = [
50+
'config',
51+
'config/jest',
52+
'config/rangle',
53+
'scripts',
54+
'scripts/utils',
55+
];
5056

5157
// Make shallow array of files paths
5258
const files = folders.reduce(
@@ -101,10 +107,10 @@ prompt(
101107
const ownPackage = require(path.join(ownPath, 'package.json'));
102108
const appPackage = require(path.join(appPath, 'package.json'));
103109
const babelConfig = JSON.parse(
104-
fs.readFileSync(path.join(ownPath, '.babelrc'), 'utf8')
110+
fs.readFileSync(path.join(ownPath, 'babelrc'), 'utf8')
105111
);
106112
const eslintConfig = JSON.parse(
107-
fs.readFileSync(path.join(ownPath, '.eslintrc'), 'utf8')
113+
fs.readFileSync(path.join(ownPath, 'eslintrc'), 'utf8')
108114
);
109115

110116
console.log(cyan('Updating the dependencies'));
@@ -179,6 +185,11 @@ prompt(
179185
}
180186
}
181187

188+
if (fs.existsSync(paths.testsCustomConfig)) {
189+
console.log(cyan('Removing custom jest-config.json...'));
190+
fs.removeSync(paths.testsCustomConfig);
191+
}
192+
182193
if (fs.existsSync(paths.yarnLockFile)) {
183194
console.log(cyan('Running yarn...'));
184195
spawnSync('yarnpkg', [], { stdio: 'inherit' });

packages/react-scripts/scripts/utils/createJestConfig.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = (resolve, rootDir, isEjecting) => {
2121

2222
// TODO: I don't know if it's safe or not to just use / as path separator
2323
// in Jest configs. We need help from somebody with Windows to determine this.
24-
const config = {
24+
let config = {
2525
collectCoverageFrom: ['src/**/*.{js,jsx}'],
2626
setupFiles: [resolve('config/polyfills.js')],
2727
setupTestFrameworkScriptFile: setupTestsFile,
@@ -45,5 +45,20 @@ module.exports = (resolve, rootDir, isEjecting) => {
4545
if (rootDir) {
4646
config.rootDir = rootDir;
4747
}
48+
49+
// If there is a jest-config.json in the root folder, merge it with
50+
// the default configuration. This allows threshold and few other
51+
// configs to be defined at the project level as you would normally do
52+
// inside your package.json -> "jest": { ... }
53+
// This solution issue will probably turn out to be something better than this,
54+
// but this change is a simple work around for now.
55+
// https://github.com/facebookincubator/create-react-app/issues/922
56+
if (fs.existsSync(paths.testsCustomConfig)) {
57+
config = Object.assign(
58+
{},
59+
config,
60+
require(paths.testsCustomConfig)
61+
);
62+
}
4863
return config;
4964
};

0 commit comments

Comments
 (0)