Skip to content

Commit a5a1efe

Browse files
Jimmy MillerGeorge Czabania
Jimmy Miller
authored and
George Czabania
committed
Made webpack respect NODE_PATH environment variable
Fixes: facebook#253
1 parent 2bb29f3 commit a5a1efe

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: config/env.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
var REACT_APP = /^REACT_APP_/i;
1616
var NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development');
17+
var NODE_PATH = process.env.NODE_PATH || '';
1718

1819
module.exports = Object
1920
.keys(process.env)
@@ -22,5 +23,6 @@ module.exports = Object
2223
env['process.env.' + key] = JSON.stringify(process.env[key]);
2324
return env;
2425
}, {
25-
'process.env.NODE_ENV': NODE_ENV
26+
'process.env.NODE_ENV': NODE_ENV,
27+
'process.env.NODE_PATH': NODE_PATH
2628
});

Diff for: config/webpack.config.dev.js

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ module.exports = {
6868
publicPath: '/'
6969
},
7070
resolve: {
71+
// This allows you to set a root for where webpack should look for modules.
72+
// This enables you to use absolute imports from the root.
73+
root: path.resolve(env['process.env.NODE_PATH']),
7174
// These are the reasonable defaults supported by the Node ecosystem.
7275
extensions: ['.js', '.json', ''],
7376
alias: {

Diff for: config/webpack.config.prod.js

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ module.exports = {
6363
publicPath: publicPath
6464
},
6565
resolve: {
66+
// This allows you to set a root for where webpack should look for modules.
67+
// This enables you to use absolute imports from the root.
68+
root: path.resolve(env['process.env.NODE_PATH']),
6669
// These are the reasonable defaults supported by the Node ecosystem.
6770
extensions: ['.js', '.json', ''],
6871
alias: {

0 commit comments

Comments
 (0)