Skip to content

Commit

Permalink
build: update paltform and implement env.config
Browse files Browse the repository at this point in the history
  • Loading branch information
mashal-m committed Jul 13, 2023
1 parent 26d8c5a commit 25a6445
Show file tree
Hide file tree
Showing 6 changed files with 27,258 additions and 17,130 deletions.
6 changes: 6 additions & 0 deletions env.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
FALSE_VALUE: false,
CORRECT_BOOL_VALUE: 'Good, false meant false. We did not cast a boolean to a string.',
INCORRECT_BOOL_VALUE: 'Why was a false boolean true?',
INTEGER_VALUE: 123,
};
12 changes: 12 additions & 0 deletions fallback.env.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
// DO NOT PUT ANY CONFIGURATION IN THIS FILE.

// The existence of this file is a technical detail of the mechanism used to implement
// env.config.js files for jest.

// This file is used as a fallback to prevent build errors if an env.config.js file has not been
// defined in a consuming application. If we could inline an empty object instead of needing a
// file to reference, that'd be clearer, but doesn't seem to be an option.

// This is NOT an appropriate place to put actual configuration values for tests.
};
15 changes: 15 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// eg.
// $ ACTIVE_ENV=<env_name> npm run build
const activeEnv = process.env.ACTIVE_ENV || process.env.NODE_ENV || 'development';
const path = require('path');

require('dotenv').config({
path: `.env.${activeEnv}`,
Expand All @@ -19,6 +20,20 @@ if (process.env.UNBRANDED_LANDING_PAGE === 'True') {
module.exports = {
pathPrefix: `${process.env.ENABLE_PATH_PREFIX ? process.env.HOSTNAME : '/'}`,
plugins: [
{
resolve: 'gatsby-plugin-alias-imports',
options: {
alias: {
'env.config': path.join(__dirname, './env.config.js'),
},
fallback: {
// This causes the system to return an empty object if it can't find an env.config.js file in
// the application being built.
'env.config': false,
},
extensions: ['.js', '.jsx'],
},
},
{
resolve: '@edx/gatsby-source-portal-designer',
options: {
Expand Down
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
const path = require('path');
const fs = require('fs');

let envConfigPath = path.join(__dirname, 'fallback.env.config.js');
const appEnvConfigPath = path.join(__dirname, 'env.config.js');

if (fs.existsSync(appEnvConfigPath)) {
envConfigPath = appEnvConfigPath;
}
module.exports = {
transform: {
'^.+\\.jsx?$': '<rootDir>/jest-preprocess.js',
},
moduleNameMapper: {
'.+\\.(css|styl|less|sass|scss)$': 'identity-obj-proxy',
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/fileTransformer.js',
'env.config': envConfigPath,
},
testPathIgnorePatterns: ['node_modules', '.cache'],
transformIgnorePatterns: ['node_modules/(?!(gatsby|@edx/paragon|@edx/frontend-platform|@edx/frontend-component-footer-edx))'],
Expand Down
Loading

0 comments on commit 25a6445

Please sign in to comment.