@@ -48,6 +48,30 @@ dotenvFiles.forEach(dotenvFile => {
48
48
}
49
49
} ) ;
50
50
51
+ const appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
52
+
53
+ /**
54
+ * Utility to parse PATH-like strings to array
55
+ *
56
+ * Separators:
57
+ * : in Unix (colon)
58
+ * ; in Windows (semicolon)
59
+ *
60
+ * @param {String } paths
61
+ * @returns {string }
62
+ */
63
+ function parsePath ( paths ) {
64
+ if ( paths ) {
65
+ return paths
66
+ . split ( path . delimiter )
67
+ . filter ( folder => folder && ! path . isAbsolute ( folder ) )
68
+ . map ( folder => path . resolve ( appDirectory , folder ) )
69
+ . join ( path . delimiter ) ;
70
+ }
71
+
72
+ return '' ;
73
+ }
74
+
51
75
// We support resolving modules according to `NODE_PATH`.
52
76
// This lets you use absolute paths in imports inside large monorepos:
53
77
// https://github.com/facebookincubator/create-react-app/issues/253.
@@ -57,12 +81,14 @@ dotenvFiles.forEach(dotenvFile => {
57
81
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
58
82
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
59
83
// We also resolve them to make sure all tools using them work consistently.
60
- const appDirectory = fs . realpathSync ( process . cwd ( ) ) ;
61
- process . env . NODE_PATH = ( process . env . NODE_PATH || '' )
62
- . split ( path . delimiter )
63
- . filter ( folder => folder && ! path . isAbsolute ( folder ) )
64
- . map ( folder => path . resolve ( appDirectory , folder ) )
65
- . join ( path . delimiter ) ;
84
+ process . env . NODE_PATH = parsePath ( process . env . NODE_PATH ) ;
85
+
86
+ // node-sass supports additional paths to resolve imports from.
87
+ // https://github.com/sass/node-sass/tree/v4.7.2#includepaths
88
+ // It works similar to NODE_PATH, but for importing scss files.
89
+ // We would like to assign an array to process.env variable, but
90
+ // Node will implicitly convert value to string.
91
+ process . env . SASS_INCLUDE_PATHS = parsePath ( process . env . SASS_INCLUDE_PATHS ) ;
66
92
67
93
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
68
94
// injected into the application via DefinePlugin in Webpack configuration.
@@ -87,6 +113,7 @@ function getClientEnvironment(publicUrl) {
87
113
PUBLIC_URL : publicUrl ,
88
114
}
89
115
) ;
116
+
90
117
// Stringify all values so we can feed into Webpack DefinePlugin
91
118
const stringified = {
92
119
'process.env' : Object . keys ( raw ) . reduce ( ( env , key ) => {
0 commit comments