File tree Expand file tree Collapse file tree 4 files changed +27
-36
lines changed
ballerina/ballerina-extension
wso2-platform/wso2-platform-extension Expand file tree Collapse file tree 4 files changed +27
-36
lines changed Original file line number Diff line number Diff line change 2323 * 3. Only define variables that are explicitly declared in .env file
2424 *
2525 * @param {Object } env - Parsed environment variables from .env file (from dotenv.config().parsed)
26- * @returns {Object } Environment variables object ready for webpack.DefinePlugin
26+ * @returns {Object } Object containing envKeys for webpack.DefinePlugin and missingVars array
2727 */
2828function createEnvDefinePlugin ( env ) {
2929
@@ -44,14 +44,7 @@ function createEnvDefinePlugin(env) {
4444 } ) ;
4545 }
4646
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 ;
47+ return { envKeys, missingVars } ;
5548 }
5649
5750 module . exports = {
Original file line number Diff line number Diff line change @@ -10,15 +10,14 @@ const { createEnvDefinePlugin } = require('../../../common/scripts/env-webpack-h
1010
1111const envPath = path . resolve ( __dirname , '.env' ) ;
1212const env = dotenv . config ( { path : envPath } ) . parsed ;
13-
14- let envKeys ;
15- try {
16- envKeys = createEnvDefinePlugin ( env ) ;
17- } catch ( error ) {
18- console . warn ( '\n⚠️ Environment Variable Configuration Warning:' ) ;
19- console . warn ( error . message ) ;
20- console . warn ( 'Continuing build with empty environment variables...' ) ;
21- envKeys = { } ;
13+ console . log ( "Fetching values for environment variables..." ) ;
14+ const { envKeys, missingVars } = createEnvDefinePlugin ( env ) ;
15+ if ( missingVars . length > 0 ) {
16+ console . warn (
17+ '\n⚠️ Environment Variable Configuration Warning:\n' +
18+ `Missing required environment variables: ${ missingVars . join ( ', ' ) } \n` +
19+ `Please provide values in either .env file or runtime environment.\n`
20+ ) ;
2221}
2322
2423/** @type {import('webpack').Configuration } */
Original file line number Diff line number Diff line change @@ -27,15 +27,14 @@ const { createEnvDefinePlugin } = require('../../../common/scripts/env-webpack-h
2727
2828const envPath = path . resolve ( __dirname , '.env' ) ;
2929const env = dotenv . config ( { path : envPath } ) . parsed ;
30-
31- let envKeys ;
32- try {
33- envKeys = createEnvDefinePlugin ( env ) ;
34- } catch ( error ) {
35- console . warn ( '\n⚠️ Environment Variable Configuration Warning:' ) ;
36- console . warn ( error . message ) ;
37- console . warn ( 'Continuing build with empty environment variables...' ) ;
38- envKeys = { } ;
30+ console . log ( "Fetching values for environment variables..." ) ;
31+ const { envKeys, missingVars } = createEnvDefinePlugin ( env ) ;
32+ if ( missingVars . length > 0 ) {
33+ console . warn (
34+ '\n⚠️ Environment Variable Configuration Warning:\n' +
35+ `Missing required environment variables: ${ missingVars . join ( ', ' ) } \n` +
36+ `Please provide values in either .env file or runtime environment.\n`
37+ ) ;
3938}
4039
4140/** @type {import('webpack').Configuration } */
Original file line number Diff line number Diff line change @@ -26,16 +26,16 @@ const { createEnvDefinePlugin } = require('../../../common/scripts/env-webpack-h
2626
2727const envPath = path . resolve ( __dirname , ".env" ) ;
2828const env = dotenv . config ( { path : envPath } ) . parsed ;
29-
30- let envKeys ;
31- try {
32- envKeys = createEnvDefinePlugin ( env ) ;
33- } catch ( error ) {
34- console . warn ( '\n⚠️ Environment Variable Configuration Warning:' ) ;
35- console . warn ( error . message ) ;
36- console . warn ( 'Continuing build with empty environment variables...' ) ;
37- envKeys = { } ;
29+ console . log ( "Fetching values for environment variables..." ) ;
30+ const { envKeys, missingVars } = createEnvDefinePlugin ( env ) ;
31+ if ( missingVars . length > 0 ) {
32+ console . warn (
33+ '\n⚠️ Environment Variable Configuration Warning:\n' +
34+ `Missing required environment variables: ${ missingVars . join ( ', ' ) } \n` +
35+ `Please provide values in either .env file or runtime environment.\n`
36+ ) ;
3837}
38+
3939//@ts -check
4040/** @typedef {import('webpack').Configuration } WebpackConfig **/
4141
You can’t perform that action at this time.
0 commit comments