Skip to content
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

Refactored webpack to work with Insights proxy #1975

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/spandx.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ const localhost = process.env.PLATFORM === 'linux' ? 'localhost' : 'host.docker.
module.exports = {
routes: {
'/apps/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
'/beta/apps/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
// New URLs
'/openshift/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
'/beta/openshift/cost-management': {
host: `https://${localhost}:8002`,
host: `http://${localhost}:8002`,
},
// For testing cloud-services-config https://github.com/RedHatInsights/cloud-services-config#testing-your-changes-locally
// '/beta/config': {
Expand Down
19 changes: 16 additions & 3 deletions scripts/start-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ const { spawn } = require('child_process');
async function setEnv() {
return inquirer
.prompt([
{ type: 'list', name: 'uiEnv', message: 'Which UI environment you want to use?', choices: ['stable', 'beta'] },
{ type: 'list', name: 'uiEnv', message: 'Which UI environment you want to use?', choices: ['beta', 'stable'] },
{
type: 'list',
name: 'clouddotEnv',
message: 'Which platform environment you want to use',
choices: ['ci', 'qa', 'prod'],
},
{
name: 'insightsProxy',
message: 'Do you want to use the Insights proxy?',
type: 'confirm',
default: false,
},
// {
// name: 'localApi',
// message: 'Do you want to use local api?',
// type: 'confirm',
// default: false,
// },
])
.then(answers => {
const { uiEnv, clouddotEnv } = answers;
const { uiEnv, clouddotEnv, insightsProxy, localApi } = answers;

process.env.BETA_ENV = uiEnv === 'beta' ? 'true' : 'false';
process.env.CLOUDOT_ENV = clouddotEnv;
process.env.USE_PROXY = 'true';
process.env.USE_PROXY = (!insightsProxy).toString(); // Set 'true' for webpack proxy
// process.env.USE_LOCAL_ROUTES = localApi.toString();
});
}

Expand Down
25 changes: 21 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = (_env, argv) => {
log.info(`Beta branches: ${betaBranches}`);
log.info(`Using deployments: ${appDeployment}`);
log.info(`Public path: ${publicPath}`);
log.info(`Using Insights proxy: ${!useProxy}`);
log.info('~~~~~~~~~~~~~~~~~~~~~');

const stats = {
Expand All @@ -90,6 +91,7 @@ module.exports = (_env, argv) => {
const routes = {
// For local API development
// '/api/cost-management/v1/': { host: 'http://localhost:8000' },
//
// For testing cloud-services-config https://github.com/RedHatInsights/cloud-services-config#testing-your-changes-locally
// '/beta/config': {
// host: `http://${localhost}:8889`,
Expand Down Expand Up @@ -257,19 +259,34 @@ module.exports = (_env, argv) => {
routes,
})
: {
host: 'localhost',
port: 8002,
stats,
contentBase: false,
historyApiFallback: {
index: `${publicPath}index.html`,
},
// hot: !isProduction,
hot: false, // default is true, which currently does not work with Insights and federated modules?
firewall: false,
transportMode: 'sockjs',
port: 8002,
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
},
// Props for webpack-dev-server v4.0.0-beta.2
//
// host: 'localhost',
// port: 8002,
// historyApiFallback: {
// index: `${publicPath}index.html`,
// },
// // hot: !isProduction,
// hot: false, // default is true, which currently does not work with Insights and federated modules?
// firewall: false,
// transportMode: 'sockjs',
// headers: {
// 'Access-Control-Allow-Origin': '*',
// 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
// },
},
};
};