Skip to content

Commit

Permalink
Made webpack respect NODE_PATH environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Miller committed Aug 22, 2016
1 parent 2b5eb82 commit cb4a48b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

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

module.exports = Object
.keys(process.env)
Expand All @@ -20,5 +21,6 @@ module.exports = Object
env['process.env.' + key] = JSON.stringify(process.env[key]);
return env;
}, {
'process.env.NODE_ENV': NODE_ENV
'process.env.NODE_ENV': NODE_ENV,
'process.env.NODE_PATH': NODE_PATH
});
3 changes: 3 additions & 0 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ module.exports = {
publicPath: '/'
},
resolve: {
// This allows you to set a root for where webpack should look for modules.
// This enables you to use absolute imports from the root.
root: path.resolve(env['process.env.NODE_PATH']),
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
alias: {
Expand Down
3 changes: 3 additions & 0 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ module.exports = {
publicPath: publicPath
},
resolve: {
// This allows you to set a root for where webpack should look for modules.
// This enables you to use absolute imports from the root.
root: path.resolve(env['process.env.NODE_PATH']),
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
alias: {
Expand Down

0 comments on commit cb4a48b

Please sign in to comment.