Skip to content

Commit afe25df

Browse files
Jimmy Millergaearon
Jimmy Miller
authored andcommitted
Made webpack respect NODE_PATH environment variable
Fixes: #253
1 parent 2f62ff8 commit afe25df

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

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
});

config/webpack.config.dev.js

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

config/webpack.config.prod.js

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

0 commit comments

Comments
 (0)