Skip to content

Commit

Permalink
refactor: expand ternary operator logic in patches and add env.config…
Browse files Browse the repository at this point in the history
….jsx to .gitignore
  • Loading branch information
jsnwesson committed Feb 9, 2024
1 parent f1347b9 commit a4689a5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ npm-debug.log
coverage
module.config.js
env.config.js
env.config.jsx

dist/
src/i18n/transifex_input.json
Expand Down
35 changes: 20 additions & 15 deletions patches/@edx+frontend-build+13.0.14.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
diff --git a/node_modules/@edx/frontend-build/config/jest.config.js b/node_modules/@edx/frontend-build/config/jest.config.js
index ae08b70..952ccc3 100644
index ae08b70..a198be1 100644
--- a/node_modules/@edx/frontend-build/config/jest.config.js
+++ b/node_modules/@edx/frontend-build/config/jest.config.js
@@ -3,12 +3,12 @@ const fs = require('fs');

@@ -4,11 +4,14 @@ const fs = require('fs');
const presets = require('../lib/presets');

-let envConfigPath = path.resolve(__dirname, './jest/fallback.env.config.js');
let envConfigPath = path.resolve(__dirname, './jest/fallback.env.config.js');
-const appEnvConfigPath = path.resolve(process.cwd(), './env.config.js');
+const appEnvConfigPathJs = path.resolve(process.cwd(), './env.config.js');
+const appEnvConfigPathJsx = path.resolve(process.cwd(), './env.config.jsx');

-if (fs.existsSync(appEnvConfigPath)) {
- envConfigPath = appEnvConfigPath;
-}
+const envConfigPath = fs.existsSync(appEnvConfigPathJs) ? appEnvConfigPathJs
+ : fs.existsSync(appEnvConfigPathJsx) ? appEnvConfigPathJsx
+ : path.resolve(__dirname, './jest/fallback.env.config.js');

+if (fs.existsSync(appEnvConfigPathJs)) {
+ envConfigPath = appEnvConfigPathJs;
+} else if (fs.existsSync(appEnvConfigPathJsx)) {
+ envConfigPath = appEnvConfigPathJsx;
+};

module.exports = {
testURL: 'http://localhost/',
diff --git a/node_modules/@edx/frontend-build/config/webpack.dev.config.js b/node_modules/@edx/frontend-build/config/webpack.dev.config.js
index 5ce7716..932a853 100644
index 5ce7716..fe9888e 100644
--- a/node_modules/@edx/frontend-build/config/webpack.dev.config.js
+++ b/node_modules/@edx/frontend-build/config/webpack.dev.config.js
@@ -7,6 +7,7 @@ const Dotenv = require('dotenv-webpack');
Expand All @@ -32,20 +33,24 @@ index 5ce7716..932a853 100644
const PostCssAutoprefixerPlugin = require('autoprefixer');
const PostCssRTLCSS = require('postcss-rtlcss');
const PostCssCustomMediaCSS = require('postcss-custom-media');
@@ -17,6 +18,12 @@ const presets = require('../lib/presets');
@@ -17,6 +18,16 @@ const presets = require('../lib/presets');
const resolvePrivateEnvConfig = require('../lib/resolvePrivateEnvConfig');
const getLocalAliases = require('./getLocalAliases');

+let envConfig = {};
+const envConfigPathJs = path.resolve(process.cwd(),'./env.config.js');
+const envConfigPathJsx = path.resolve(process.cwd(), './env.config.jsx');
+const envConfig = fs.existsSync(envConfigPathJs) ? require(envConfigPathJs)
+ : fs.existsSync(envConfigPathJsx) ? require(envConfigPathJsx)
+ : {};
+
+if (fs.existsSync(envConfigPathJs)) {
+ envConfig = require(envConfigPathJs);
+} else if (fs.existsSync(envConfigPathJsx)) {
+ envConfig = require(envConfigPathJsx);
+};
+
// Add process env vars. Currently used only for setting the
// server port and the publicPath
dotenv.config({
@@ -174,7 +181,7 @@ module.exports = merge(commonConfig, {
@@ -174,7 +185,7 @@ module.exports = merge(commonConfig, {
// reloading.
devServer: {
host: '0.0.0.0',
Expand Down

0 comments on commit a4689a5

Please sign in to comment.