File tree Expand file tree Collapse file tree 1 file changed +30
-31
lines changed Expand file tree Collapse file tree 1 file changed +30
-31
lines changed Original file line number Diff line number Diff line change 2626 * @returns {Object } Environment variables object ready for webpack.DefinePlugin
2727 */
2828function createEnvDefinePlugin ( env ) {
29-
30- const envKeys = Object . create ( null ) ;
31- const missingVars = [ ] ;
32-
33- if ( env ) {
34- Object . entries ( env ) . forEach ( ( [ key , value ] ) => {
35- if ( value !== undefined && value !== '' ) {
36- envKeys [ `process.env.${ key } ` ] = JSON . stringify ( value ) ;
37- }
38- else if ( process . env [ key ] !== undefined && process . env [ key ] !== '' ) {
39- envKeys [ `process.env.${ key } ` ] = JSON . stringify ( process . env [ key ] ) ;
40- }
41- else {
42- missingVars . push ( key ) ;
43- }
44- } ) ;
45- }
46-
47- if ( missingVars . length > 0 ) {
48- throw new Error (
49- `Missing required environment variables: ${ missingVars . join ( ', ' ) } \n` +
50- `Please provide values in either .env file or runtime environment.\n`
51- ) ;
52- }
53-
54- return envKeys ;
29+
30+ const envKeys = Object . create ( null ) ;
31+ const missingVars = [ ] ;
32+
33+ if ( env ) {
34+ Object . entries ( env ) . forEach ( ( [ key , value ] ) => {
35+ if ( value !== undefined && value !== '' ) {
36+ envKeys [ `process.env.${ key } ` ] = JSON . stringify ( value ) ;
37+ }
38+ else if ( process . env [ key ] !== undefined && process . env [ key ] !== '' ) {
39+ envKeys [ `process.env.${ key } ` ] = JSON . stringify ( process . env [ key ] ) ;
40+ }
41+ else {
42+ missingVars . push ( key ) ;
43+ }
44+ } ) ;
45+ }
46+
47+ if ( missingVars . length > 0 ) {
48+ throw new Error (
49+ `Missing required environment variables: ${ missingVars . join ( ', ' ) } \n` +
50+ `Please provide values in either .env file or runtime environment.\n`
51+ ) ;
5552 }
56-
57- module . exports = {
58- createEnvDefinePlugin
59- } ;
60-
53+
54+ return envKeys ;
55+ }
56+
57+ module . exports = {
58+ createEnvDefinePlugin
59+ } ;
You can’t perform that action at this time.
0 commit comments