Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
c71337f6
Commit
c71337f6
authored
8 years ago
by
Dan Abramov
Browse files
Options
Download
Email Patches
Plain Diff
Tweak how NODE_PATH is handled
parent
82066ac4
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/paths.js
+7
-3
config/paths.js
config/webpack.config.dev.js
+6
-5
config/webpack.config.dev.js
config/webpack.config.prod.js
+6
-5
config/webpack.config.prod.js
with
19 additions
and
13 deletions
+19
-13
config/paths.js
+
7
-
3
View file @
c71337f6
...
...
@@ -11,13 +11,17 @@
var
path
=
require
(
'
path
'
);
// We support resolving modules according to NODE_PATH.
// We support resolving modules according to
`
NODE_PATH
`
.
// This lets you use absolute paths in imports inside large monorepos:
// https://github.com/facebookincubator/create-react-app/issues/253.
// It works just like NODE_PATH in Node:
// It works similar to `NODE_PATH` in Node itself:
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
// We will export `nodePaths` as an array of absolute paths.
// It will then be used by Webpack (and potentially other tools).
// It will then be used by Webpack configs.
// Jest doesn’t need this because it already handles `NODE_PATH` out of the box.
var
nodePaths
=
(
process
.
env
.
NODE_PATH
||
''
)
.
split
(
process
.
platform
===
'
win32
'
?
'
;
'
:
'
:
'
)
.
filter
(
Boolean
)
...
...
This diff is collapsed.
Click to expand it.
config/webpack.config.dev.js
+
6
-
5
View file @
c71337f6
...
...
@@ -67,11 +67,12 @@ module.exports = {
publicPath
:
'
/
'
},
resolve
:
{
// This allows you to set a root for where Webpack should look for modules.
// It must be an absolute path or an array of absolute paths.
// This lets you use absolute paths in imports inside large monorepos:
// https://github.com/facebookincubator/create-react-app/issues/253.
root
:
paths
.
nodePaths
,
// This allows you to set a fallback for where Webpack should look for modules.
// We read `NODE_PATH` environment variable in `paths.js` and pass paths here.
// We use `fallback` instead of `root` because we want `node_modules` to "win"
// if there any conflicts. This matches Node resolution mechanism.
// https://github.com/facebookincubator/create-react-app/issues/253
fallback
:
paths
.
nodePaths
,
// These are the reasonable defaults supported by the Node ecosystem.
extensions
:
[
'
.js
'
,
'
.json
'
,
''
],
alias
:
{
...
...
This diff is collapsed.
Click to expand it.
config/webpack.config.prod.js
+
6
-
5
View file @
c71337f6
...
...
@@ -62,11 +62,12 @@ module.exports = {
publicPath
:
publicPath
},
resolve
:
{
// This allows you to set a root for where Webpack should look for modules.
// It must be an absolute path or an array of absolute paths.
// This lets you use absolute paths in imports inside large monorepos:
// https://github.com/facebookincubator/create-react-app/issues/253.
root
:
paths
.
nodePaths
,
// This allows you to set a fallback for where Webpack should look for modules.
// We read `NODE_PATH` environment variable in `paths.js` and pass paths here.
// We use `fallback` instead of `root` because we want `node_modules` to "win"
// if there any conflicts. This matches Node resolution mechanism.
// https://github.com/facebookincubator/create-react-app/issues/253
fallback
:
paths
.
nodePaths
,
// These are the reasonable defaults supported by the Node ecosystem.
extensions
:
[
'
.js
'
,
'
.json
'
,
''
],
alias
:
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets