fix(webpack-dev-server): parse env args (#19744)

This commit is contained in:
Jeremy 2024-02-07 15:59:41 -06:00 committed by GitHub
parent 686ce33ea5
commit e986a1746f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -695,10 +695,10 @@ npm run dev-server
npm run dev-server -- --port=9001 npm run dev-server -- --port=9001
# Proxy backend requests to a Flask server running on a non-default port # Proxy backend requests to a Flask server running on a non-default port
npm run dev-server -- --supersetPort=8081 npm run dev-server -- --env=--supersetPort=8081
# Proxy to a remote backend but serve local assets # Proxy to a remote backend but serve local assets
npm run dev-server -- --superset=https://superset-dev.example.com npm run dev-server -- --env=--superset=https://superset-dev.example.com
``` ```
The `--superset=` option is useful in case you want to debug a production issue or have to setup Superset behind a firewall. It allows you to run Flask server in another environment while keep assets building locally for the best developer experience. The `--superset=` option is useful in case you want to debug a production issue or have to setup Superset behind a firewall. It allows you to run Flask server in another environment while keep assets building locally for the best developer experience.

View File

@ -18,10 +18,18 @@
*/ */
const zlib = require('zlib'); const zlib = require('zlib');
const yargs = require('yargs');
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
const parsedArgs = require('yargs').argv; const parsedArgs = yargs.argv;
const { supersetPort = 8088, superset: supersetUrl = null } = parsedArgs; const parsedEnvArg = () => {
if (parsedArgs.env) {
return yargs(parsedArgs.env).argv;
}
return {};
};
const { supersetPort = 8088, superset: supersetUrl = null } = parsedEnvArg();
const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace( const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
'//+$/', '//+$/',
'', '',