From e986a1746f45423064f28df507b2f7ed97189352 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Wed, 7 Feb 2024 15:59:41 -0600 Subject: [PATCH] fix(webpack-dev-server): parse env args (#19744) --- CONTRIBUTING.md | 4 ++-- superset-frontend/webpack.proxy-config.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e95a766dc..4afa69eb2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -695,10 +695,10 @@ npm run dev-server npm run dev-server -- --port=9001 # 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 -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. diff --git a/superset-frontend/webpack.proxy-config.js b/superset-frontend/webpack.proxy-config.js index ebac68994..29823144d 100644 --- a/superset-frontend/webpack.proxy-config.js +++ b/superset-frontend/webpack.proxy-config.js @@ -18,10 +18,18 @@ */ const zlib = require('zlib'); +const yargs = require('yargs'); // 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( '//+$/', '',