Skip to content

Commit f93595c

Browse files
committed
remove custom aliases
add src to aliases
1 parent c39e304 commit f93595c

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2222
const getClientEnvironment = require('./env');
2323
const paths = require('./paths');
2424

25-
const appPackage = require(paths.appPackageJson);
26-
2725
// Webpack uses `publicPath` to determine where the app is being served from.
2826
// In development, we always serve from the root. This makes config easier.
2927
const publicPath = '/';
@@ -34,13 +32,6 @@ const publicUrl = '';
3432
// Get environment variables to inject into our app.
3533
const env = getClientEnvironment(publicUrl);
3634

37-
const alias = !appPackage.alias
38-
? {}
39-
: Object.keys(appPackage.alias).reduce((previous, current) => {
40-
previous[current] = path.resolve(paths.appPath, appPackage.alias[current]);
41-
return previous;
42-
}, {});
43-
4435
// This is the development configuration.
4536
// It is focused on developer experience and fast rebuilds.
4637
// The production configuration is different and lives in a separate file.
@@ -107,7 +98,7 @@ module.exports = {
10798
// `web` extension prefixes have been added for better support
10899
// for React Native Web.
109100
extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
110-
alias: Object.assign({}, alias, {
101+
alias: {
111102
// @remove-on-eject-begin
112103
// Resolve Babel runtime relative to react-scripts.
113104
// It usually still works on npm 3 without this but it would be
@@ -120,7 +111,8 @@ module.exports = {
120111
// Support React Native Web
121112
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
122113
'react-native': 'react-native-web',
123-
}),
114+
'src': paths.appSrc,
115+
},
124116
plugins: [
125117
// Prevents users from importing files from outside of src/ (or node_modules/).
126118
// This often causes confusion because we only process files within src/ with babel.

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2323
const paths = require('./paths');
2424
const getClientEnvironment = require('./env');
2525

26-
const appPackage = require(paths.appPackageJson);
27-
2826
// Webpack uses `publicPath` to determine where the app is being served from.
2927
// It requires a trailing slash, or the file assets will get an incorrect path.
3028
const publicPath = paths.servedPath;
@@ -56,13 +54,6 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
5654
{ publicPath: Array(cssFilename.split('/').length).join('../') }
5755
: {};
5856

59-
const alias = !appPackage.alias
60-
? {}
61-
: Object.keys(appPackage.alias).reduce((previous, current) => {
62-
previous[current] = path.resolve(paths.appPath, appPackage.alias[current]);
63-
return previous;
64-
}, {});
65-
6657
// This is the production configuration.
6758
// It compiles slowly and is focused on producing a fast and minimal bundle.
6859
// The development configuration is different and lives in a separate file.
@@ -106,7 +97,7 @@ module.exports = {
10697
// `web` extension prefixes have been added for better support
10798
// for React Native Web.
10899
extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
109-
alias: Object.assign({}, alias, {
100+
alias: {
110101
// @remove-on-eject-begin
111102
// Resolve Babel runtime relative to react-scripts.
112103
// It usually still works on npm 3 without this but it would be
@@ -119,7 +110,8 @@ module.exports = {
119110
// Support React Native Web
120111
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
121112
'react-native': 'react-native-web',
122-
}),
113+
'src': paths.appSrc,
114+
},
123115
plugins: [
124116
// Prevents users from importing files from outside of src/ (or node_modules/).
125117
// This often causes confusion because we only process files within src/ with babel.

0 commit comments

Comments
 (0)