-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set up dashboard to deploy js configs (#304)
- Loading branch information
Showing
5 changed files
with
230 additions
and
19 deletions.
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