Skip to content

Commit 4b33b47

Browse files
committed
Customize for our usecases
1 parent 2e02e36 commit 4b33b47

File tree

10 files changed

+48
-27
lines changed

10 files changed

+48
-27
lines changed

packages/babel-preset-react-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "babel-preset-react-app",
34
"version": "2.0.1",
45
"description": "Babel preset used by Create React App",

packages/create-react-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "create-react-app",
34
"version": "1.0.1",
45
"keywords": [

packages/eslint-config-react-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "eslint-config-react-app",
34
"version": "0.5.0",
45
"description": "ESLint configuration used by Create React App",

packages/react-dev-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"private": true,
23
"name": "react-dev-utils",
34
"version": "0.4.1",
45
"description": "Webpack utilities used by Create React App",

packages/react-scripts/.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "react-app"
2+
"extends": "react-app",
3+
"rules": {
4+
"react/react-in-jsx-scope": "off"
5+
}
36
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
plugins: [
3+
// Turns JSX into createElement() calls
4+
[require.resolve('babel-plugin-transform-react-jsx'), {
5+
pragma: 'createElement',
6+
}],
7+
// Import react automatically, as need, when JSX is used
8+
[require.resolve('babel-plugin-jsx-pragmatic'), {
9+
module: 'react',
10+
import: 'createElement',
11+
export: 'createElement'
12+
}]
13+
]
14+
};

packages/react-scripts/config/paths.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,3 @@ module.exports = {
7575
ownNodeModules: resolveOwn('../node_modules'),
7676
nodePaths: nodePaths
7777
};
78-
79-
// config before publish: we're in ./packages/react-scripts/config/
80-
if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) {
81-
module.exports = {
82-
appBuild: resolveOwn('../../../build'),
83-
appPublic: resolveOwn('../template/public'),
84-
appHtml: resolveOwn('../template/public/index.html'),
85-
appIndexJs: resolveOwn('../template/src/index.js'),
86-
appPackageJson: resolveOwn('../package.json'),
87-
appSrc: resolveOwn('../template/src'),
88-
yarnLockFile: resolveOwn('../template/yarn.lock'),
89-
testsSetup: resolveOwn('../template/src/setupTests.js'),
90-
appNodeModules: resolveOwn('../node_modules'),
91-
ownNodeModules: resolveOwn('../node_modules'),
92-
nodePaths: nodePaths
93-
};
94-
}
95-
// @remove-on-eject-end

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var paths = require('./paths');
2323
var path = require('path');
2424
// @remove-on-eject-end
2525

26+
var ComponentResolverPlugin = require('component-resolver-webpack');
27+
2628
// Webpack uses `publicPath` to determine where the app is being served from.
2729
// In development, we always serve from the root. This makes config easier.
2830
var publicPath = '/';
@@ -88,6 +90,7 @@ module.exports = {
8890
// https://github.com/facebookincubator/create-react-app/issues/290
8991
extensions: ['.js', '.json', '.jsx', ''],
9092
alias: {
93+
'~': paths.appSrc,
9194
// Support React Native Web
9295
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
9396
'react-native': 'react-native-web'
@@ -147,8 +150,8 @@ module.exports = {
147150
loader: 'babel',
148151
query: {
149152
// @remove-on-eject-begin
150-
babelrc: false,
151-
presets: [require.resolve('babel-preset-react-app')],
153+
babelrc: true,
154+
presets: [require.resolve('babel-preset-react-app'), require.resolve('./babel-preset-custom')],
152155
// @remove-on-eject-end
153156
// This is a feature of `babel-loader` for webpack (not Babel itself).
154157
// It enables caching results in ./node_modules/.cache/babel-loader/
@@ -185,7 +188,7 @@ module.exports = {
185188
// Point ESLint to our predefined config.
186189
eslint: {
187190
configFile: path.join(__dirname, '../.eslintrc'),
188-
useEslintrc: false
191+
useEslintrc: true
189192
},
190193
// @remove-on-eject-end
191194
// We use PostCSS for autoprefixing only.
@@ -202,6 +205,11 @@ module.exports = {
202205
];
203206
},
204207
plugins: [
208+
// Allows us to resolve files without duplicating filename
209+
// like "./Button"" could be resolved to "./Button/Button.js""
210+
new webpack.ResolverPlugin([
211+
new ComponentResolverPlugin(['jsx', 'js', 'css'])
212+
]),
205213
// Makes the public URL available as %PUBLIC_URL% in index.html, e.g.:
206214
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
207215
// In development, this will be an empty string.

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var getClientEnvironment = require('./env');
2525
var path = require('path');
2626
// @remove-on-eject-end
2727

28+
var ComponentResolverPlugin = require('component-resolver-webpack');
29+
2830
function ensureSlash(path, needsSlash) {
2931
var hasSlash = path.endsWith('/');
3032
if (hasSlash && !needsSlash) {
@@ -158,8 +160,8 @@ module.exports = {
158160
loader: 'babel',
159161
// @remove-on-eject-begin
160162
query: {
161-
babelrc: false,
162-
presets: [require.resolve('babel-preset-react-app')],
163+
babelrc: true,
164+
presets: [require.resolve('babel-preset-react-app'), require.resolve('./babel-preset-custom')],
163165
},
164166
// @remove-on-eject-end
165167
},
@@ -202,7 +204,7 @@ module.exports = {
202204
// TODO: consider separate config for production,
203205
// e.g. to enable no-console and no-debugger only in production.
204206
configFile: path.join(__dirname, '../.eslintrc'),
205-
useEslintrc: false
207+
useEslintrc: true
206208
},
207209
// @remove-on-eject-end
208210
// We use PostCSS for autoprefixing only.
@@ -219,6 +221,11 @@ module.exports = {
219221
];
220222
},
221223
plugins: [
224+
// Allows us to resolve files without duplicating filename
225+
// like "./Button"" could be resolved to "./Button/Button.js""
226+
new webpack.ResolverPlugin([
227+
new ComponentResolverPlugin(['jsx', 'js', 'css'])
228+
]),
222229
// Makes the public URL available as %PUBLIC_URL% in index.html, e.g.:
223230
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
224231
// In production, it will be an empty string unless you specify "homepage"

packages/react-scripts/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "react-scripts",
3-
"version": "0.8.3",
2+
"name": "@jayphelps/react-scripts",
3+
"version": "0.0.1",
44
"description": "Configuration and scripts for Create React App.",
55
"repository": "facebookincubator/create-react-app",
66
"license": "BSD-3-Clause",
@@ -28,9 +28,12 @@
2828
"babel-eslint": "7.0.0",
2929
"babel-jest": "17.0.2",
3030
"babel-loader": "6.2.7",
31+
"babel-plugin-jsx-pragmatic": "1.0.2",
32+
"babel-plugin-transform-react-jsx": "6.8.0",
3133
"babel-preset-react-app": "^2.0.1",
3234
"case-sensitive-paths-webpack-plugin": "1.1.4",
3335
"chalk": "1.1.3",
36+
"component-resolver-webpack": "0.4.0",
3437
"connect-history-api-fallback": "1.3.0",
3538
"cross-spawn": "4.0.2",
3639
"css-loader": "0.26.0",

0 commit comments

Comments
 (0)