Skip to content

Commit

Permalink
Merge pull request #2064 from Expensify/Rory-FixStagingCORS
Browse files Browse the repository at this point in the history
Create separate build configuration for staging
  • Loading branch information
MariaHCD authored Mar 25, 2021
2 parents 2b0674b + 15354b8 commit 18f59c7
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
EXPENSIFY_URL_CASH=https://staging.expensify.cash/
EXPENSIFY_URL_COM=https://www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
2 changes: 1 addition & 1 deletion .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Build staging desktop app
if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }}
run: npm run desktop-build -- --publish always -c.afterSign=desktop/notarize.js
run: npm run desktop-build-staging -- --publish always -c.afterSign=desktop/notarize.js
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ jobs:
max_attempts: 5
command: npm ci

- name: Build web
- name: Build web for production
if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }}
run: npm run build

- name: Deploy production to S3
if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }}
run: aws s3 cp --recursive --acl public-read $GITHUB_WORKSPACE/dist s3://expensify-cash/

- name: Build web for staging
if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }}
run: npm run build-staging

- name: Deploy staging to S3
if: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'false' }}
run: aws s3 cp --recursive --acl public-read $GITHUB_WORKSPACE/dist s3://staging-expensify-cash/
Expand Down
29 changes: 29 additions & 0 deletions config/webpack/productionConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const webpack = require('webpack');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');

/**
* Get the production webpack configuration, given an environment object.
*
* @param {Object} env
* @returns {Object}
*/
function getProductionConfig(env) {
return ({
mode: 'production',
devtool: 'source-map',
plugins: [
// This allows us to interactively inspect JS bundle contents
...(process.env.ANALYZE_BUNDLE === 'true' ? [new BundleAnalyzerPlugin()] : []),
new webpack.DefinePlugin({
__REACT_WEB_CONFIG__: JSON.stringify(env),

// React Native JavaScript environment requires the global __DEV__ variable to be accessible.
// react-native-render-html uses variable to log exclusively during development.
// See https://reactnative.dev/docs/javascript-environment
__DEV__: false,
}),
],
});
}

module.exports = getProductionConfig;
20 changes: 2 additions & 18 deletions config/webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
const path = require('path');
const webpack = require('webpack');
const {merge} = require('webpack-merge');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const dotenv = require('dotenv');
const common = require('./webpack.common.js');
const getProductionConfig = require('./productionConfig');

const env = dotenv.config({path: path.resolve(__dirname, '../../.env.production')}).parsed;

module.exports = merge(common, {
mode: 'production',
devtool: 'source-map',
plugins: [
// This allows us to interactively inspect JS bundle contents
...(process.env.ANALYZE_BUNDLE === 'true' ? [new BundleAnalyzerPlugin()] : []),
new webpack.DefinePlugin({
__REACT_WEB_CONFIG__: JSON.stringify(env),

// React Native JavaScript environment requires the global __DEV__ variable to be accessible.
// react-native-render-html uses variable to log exclusively during development.
// See https://reactnative.dev/docs/javascript-environment
__DEV__: false,
}),
],
});
module.exports = merge(common, getProductionConfig(env));
9 changes: 9 additions & 0 deletions config/webpack/webpack.staging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('path');
const {merge} = require('webpack-merge');
const dotenv = require('dotenv');
const common = require('./webpack.common.js');
const getProductionConfig = require('./productionConfig');

const env = dotenv.config({path: path.resolve(__dirname, '../../.env.staging')}).parsed;

module.exports = merge(common, getProductionConfig(env));
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"start": "react-native start",
"web": "node web/proxy.js & webpack-dev-server --open --config config/webpack/webpack.dev.js",
"build": "webpack --config config/webpack/webpack.prod.js",
"build-staging": "webpack --config config/webpack/webpack.staging.js",
"desktop-build": "webpack --config config/webpack/webpack.prod.js --platform desktop && electron-builder --config config/electron.config.js",
"desktop-build-staging": "webpack --config config/webpack/webpack.staging.js --platform desktop && electron-builder --config config/electron.config.js",
"ios-build": "fastlane ios build",
"android-build": "fastlane android build",
"test": "jest",
Expand Down

0 comments on commit 18f59c7

Please sign in to comment.