Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 129aeaa

Browse files
committed
fix(packages/webpack): improve webpack watching scripts for dockerized runs
A few minor tweaks are needed to support running the watcher in a docker container
1 parent b0e2b7c commit 129aeaa

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/webpack/bin/watch.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ set -o pipefail
2222
SCRIPTDIR=$(cd $(dirname "$0") && pwd)
2323
export CLIENT_HOME=$(cd "$SCRIPTDIR"/../../ && pwd)
2424

25+
export KUI_BUILDDIR=${BUILDDIR-"$CLIENT_HOME"/dist/webpack}
26+
2527
if [ -d "$SCRIPTDIR"/../@kui-shell ]; then
2628
# normally, this is in node_modules/.bin
2729
MODULE_HOME=$(cd "$SCRIPTDIR"/../@kui-shell && pwd)
@@ -37,9 +39,7 @@ HEADLESS_CONFIG="$MODULE_HOME"/webpack/headless-webpack.config.js
3739

3840
THEME="${MODULE_HOME}"/client
3941

40-
pushd "$CLIENT_HOME"
41-
rm -rf dist/webpack
42-
popd
42+
rm -rf "$KUI_BUILDDIR"/dist/webpack/*
4343

4444
if [ -n "$OPEN" ]; then
4545
OPEN="--open"
@@ -73,4 +73,6 @@ fi
7373

7474
if [ "$WATCH_ARGS" = "open" ]; then
7575
npm run open
76+
elif [ "$WATCH_ARGS" = "wait" ]; then
77+
wait
7678
fi

packages/webpack/webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ module.exports = {
416416
devMiddleware: {
417417
writeToDisk: !inBrowser
418418
},
419+
host: '0.0.0.0',
419420
allowedHosts:
420421
'all' /* webpack 4.43 -> 4.44 seemed to require this, otherwise console errors WDS Disconnected, and no auto-reload on save+recompile */,
421422
port
@@ -513,7 +514,11 @@ module.exports = {
513514
output: {
514515
globalObject: 'self', // for monaco
515516
filename: mode === 'production' ? '[name].[contenthash].bundle.js' : '[name].bundle.js',
516-
publicPath: contextRoot || (inBrowser ? '/' : mode === 'production' ? '' : `${buildDir}/`),
517+
518+
// live watching should never use a contextRoot, otherwise you
519+
// will get "Cannot GET /" errors
520+
publicPath:
521+
(process.env.WATCH !== 'true' && contextRoot) || (inBrowser ? '/' : mode === 'production' ? '' : `${buildDir}/`),
517522
path: outputPath
518523
}
519524
}

0 commit comments

Comments
 (0)