-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: set up dashboard to deploy js configs #304
Merged
jsnwesson
merged 6 commits into
master
from
jwesson/set-up-dashboard-to-deploy-js-configs
Mar 28, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
78b30d8
feat: add js config compatibility to mfe prod build
jsnwesson ec7069b
Merge branch 'master' into jwesson/set-up-dashboard-to-deploy-js-configs
jsnwesson 8d6204a
fix: mock variables for jest test
jsnwesson ef4b7ec
feat: merge JS config variables in initialized config
jsnwesson 14a9355
Merge branch 'master' into jwesson/set-up-dashboard-to-deploy-js-configs
jsnwesson 57d3b5a
refactor: remove over-write of environment variables in configuration.js
jsnwesson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.DS_Store | ||
.eslintcache | ||
env.config.js | ||
env.config.* | ||
node_modules | ||
npm-debug.log | ||
coverage | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
diff --git a/node_modules/@openedx/frontend-build/config/jest.config.js b/node_modules/@openedx/frontend-build/config/jest.config.js | ||
index ac5f730..ddce396 100644 | ||
--- a/node_modules/@openedx/frontend-build/config/jest.config.js | ||
+++ b/node_modules/@openedx/frontend-build/config/jest.config.js | ||
@@ -3,11 +3,16 @@ const fs = require('fs'); | ||
|
||
const presets = require('../lib/presets'); | ||
|
||
+// This assigns the envConfigPath filepath based on whether env.config exists, otherwise it uses the fallback filepath. | ||
+ | ||
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; | ||
+if (fs.existsSync(appEnvConfigPathJs)) { | ||
+ envConfigPath = appEnvConfigPathJs; | ||
+} else if (fs.existsSync(appEnvConfigPathJsx)) { | ||
+ envConfigPath = appEnvConfigPathJsx; | ||
} | ||
|
||
module.exports = { | ||
diff --git a/node_modules/@openedx/frontend-build/config/webpack.prod.config.js b/node_modules/@openedx/frontend-build/config/webpack.prod.config.js | ||
index 2879dd9..dd819bc 100644 | ||
--- a/node_modules/@openedx/frontend-build/config/webpack.prod.config.js | ||
+++ b/node_modules/@openedx/frontend-build/config/webpack.prod.config.js | ||
@@ -11,6 +11,7 @@ const dotenv = require('dotenv'); | ||
const NewRelicSourceMapPlugin = require('@edx/new-relic-source-map-webpack-plugin'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
+const fs = require('fs'); | ||
const path = require('path'); | ||
const PostCssAutoprefixerPlugin = require('autoprefixer'); | ||
const PostCssRTLCSS = require('postcss-rtlcss'); | ||
@@ -23,6 +24,21 @@ const HtmlWebpackNewRelicPlugin = require('../lib/plugins/html-webpack-new-relic | ||
const commonConfig = require('./webpack.common.config'); | ||
const presets = require('../lib/presets'); | ||
|
||
+/** This condition confirms whether the configuration for the MFE has switched to a JS-based configuration | ||
+ * as previously implemented in frontend-build and frontend-platform. If the environment variable exists, then | ||
+ * an env.config.js file will be created at the root directory and its env variables can be accessed with getConfig(). | ||
+ * | ||
+ * https://github.com/openedx/frontend-build/blob/master/docs/0002-js-environment-config.md | ||
+ * https://github.com/openedx/frontend-platform/blob/master/docs/decisions/0007-javascript-file-configuration.rst | ||
+ */ | ||
+ | ||
+const envConfigPath = process.env.JS_CONFIG_FILEPATH; | ||
+ | ||
+if (envConfigPath) { | ||
+ const envConfigFilename = envConfigPath.slice(envConfigPath.indexOf('env.config')); | ||
+ fs.copyFileSync(envConfigPath, envConfigFilename); | ||
+} | ||
+ | ||
// Add process env vars. Currently used only for setting the PUBLIC_PATH. | ||
dotenv.config({ | ||
path: path.resolve(process.cwd(), '.env'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not already happen in frontend-platform?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it does, and I realize now that I added this additional
mergeConfig
because at one point I was trying to handle the scenario where the.env.*
files would be removed, but I now know that that isn't something I should have to anticipate while adding the risk of variables over-writing each other repeatedly. Removing this logic for now.