Compare commits

...

10 Commits

Author SHA1 Message Date
hainenber
8bf9f8ce94 Merge branch 'master' into fix/resolve-custom-inputs-not-passed-to-webpack-configs
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-10-02 21:23:35 +07:00
hainenber
8872ac15dd chore: revert doc update in versioned doc which was already published
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-10-01 00:35:31 +07:00
hainenber
c2011199cf doc(contrib/dev): update example to pass env vars to npm run dev-server command similar to webpack-cli
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-10-01 00:35:13 +07:00
Đỗ Trọng Hải
bfc2680b0e Merge branch 'master' into fix/resolve-custom-inputs-not-passed-to-webpack-configs 2026-09-28 21:29:47 +07:00
hainenber
1edd394a32 Merge branch 'master' into fix/resolve-custom-inputs-not-passed-to-webpack-configs
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-09-27 08:44:06 +07:00
Đỗ Trọng Hải
fa0f7a9363 Merge branch 'master' into fix/resolve-custom-inputs-not-passed-to-webpack-configs 2026-09-22 22:06:10 +07:00
Đỗ Trọng Hải
7b646d3a29 Merge branch 'master' into fix/resolve-custom-inputs-not-passed-to-webpack-configs 2026-09-22 21:14:42 +07:00
hainenber
69c69ef593 chore: collapse extraneous defautEntryFilename conditionals
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-09-22 21:13:42 +07:00
hainenber
3f6e4e831a chore: update Webpack config import when building Storybooks
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-09-20 16:50:06 +07:00
hainenber
790db853aa fix(build): resolve custom built inputs not passed to Webpack configs
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-09-20 16:01:57 +07:00
8 changed files with 692 additions and 697 deletions

View File

@@ -643,13 +643,13 @@ 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 -- --env=--supersetPort=8081
npm run dev-server -- --env supersetPort=8081
# Proxy to a remote backend but serve local assets
npm run dev-server -- --env=--superset=https://superset-dev.example.com
npm run dev-server -- --env supersetUrl=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 `--supersetUrl=` 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.
#### Other npm commands

View File

@@ -22,11 +22,13 @@ import path from 'node:path';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
// Superset's webpack.config.js
import customConfig from '../webpack.config.js';
import generateWebpackConfig from '../webpack.config.js';
const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const customConfig = generateWebpackConfig();
// Filter out plugins that shouldn't be included in Storybook's static build
// ReactRefreshWebpackPlugin adds Fast Refresh code that requires a dev server runtime,
// which isn't available when serving the static storybook build

View File

@@ -150,8 +150,7 @@
"use-immer": "^0.11.0",
"use-query-params": "^2.2.2",
"uuid": "^14.0.2",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yargs": "^18.1.0"
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
"@babel/cli": "^7.29.7",

View File

@@ -227,8 +227,7 @@
"use-immer": "^0.11.0",
"use-query-params": "^2.2.2",
"uuid": "^14.0.2",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yargs": "^18.1.0"
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
},
"devDependencies": {
"@babel/cli": "^7.29.7",

View File

@@ -26,13 +26,22 @@
import { spawnSync } from 'node:child_process';
import { globSync } from 'node:fs';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { parseArgs } from 'node:util';
process.env.PATH = `./node_modules/.bin:${process.env.PATH}`;
const { globs } = yargs(hideBin(process.argv)).parse();
const glob = globs?.length > 1 ? `{${globs.join(',')}}` : globs?.[0] || '*';
const cliOptions = {
globs: {
type: 'string',
multiple: true,
default: ['*'],
},
};
const { values } = parseArgs({ options: cliOptions });
const glob =
values.globs?.length > 1 ? `{${values.globs.join(',')}}` : values.globs?.[0];
const BABEL_CONFIG = '--config-file=../../babel.config.js';

View File

@@ -21,14 +21,6 @@ import zlib from 'node:zlib';
import { ZSTDCompress } from 'simple-zstd';
import { createProxyMiddleware } from 'http-proxy-middleware';
// yargs ships ESM-only and jest's default transform doesn't cover
// node_modules; webpack.proxy-config.js only uses it to parse a `--env`
// CLI flag we don't exercise here (the target port is set via
// process.env.supersetPort below), so stub it out rather than teaching
// the whole suite's transformIgnorePatterns about it.
jest.mock('yargs', () => jest.fn(() => ({ parse: () => ({}) })));
jest.mock('yargs/helpers', () => ({ hideBin: argv => argv }));
const HANG_GUARD_MS = 2000;
/**

File diff suppressed because it is too large Load Diff

View File

@@ -21,23 +21,7 @@ import { Writable } from 'node:stream';
import { pipeline } from 'node:stream/promises';
import { ZSTDDecompress } from 'simple-zstd';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const parsedArgs = yargs(hideBin(process.argv)).parse();
const parsedEnvArg = () => {
let envArgs = {};
if (parsedArgs.env) {
envArgs = yargs(parsedArgs.env).argv;
}
return { ...process.env, ...envArgs };
};
const { supersetPort = 8088, superset: supersetUrl = null } = parsedEnvArg();
const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
'//+$/',
'',
); // strip ending backslash
const importTimeEnvVars = Object.freeze({ ...process.env });
let manifest;
function isHTML(res) {
@@ -88,7 +72,7 @@ function toDevHTML(originalHtml) {
return html;
}
function copyHeaders(originalResponse, response) {
function copyHeaders(originalResponse, response, backend) {
response.statusCode = originalResponse.statusCode;
response.statusMessage = originalResponse.statusMessage;
if (response.setHeader) {
@@ -185,7 +169,14 @@ async function processHTML(proxyResponse, response) {
response.end(toDevHTML(Buffer.concat(chunks).toString()));
}
export default function getProxyConfig(newManifest) {
export default function getProxyConfig(newManifest, env = {}) {
const parsedEnvArgs = { ...importTimeEnvVars, ...env };
const { supersetPort = 8088, supersetUrl = null } = parsedEnvArgs;
const backend = (supersetUrl || `http://localhost:${supersetPort}`).replace(
'//+$/',
'',
); // strip ending backslash
manifest = newManifest;
return {
context: path => {
@@ -206,7 +197,7 @@ export default function getProxyConfig(newManifest) {
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
onProxyRes(proxyResponse, request, response) {
try {
copyHeaders(proxyResponse, response);
copyHeaders(proxyResponse, response, backend);
if (isHTML(response)) {
// For HTML responses, flush headers before processing starts.
// processHTML awaits pipeline() and calls response.end() once it