angular

how to change `adev` http server port?


I change all places about port in the adev/BUILD.bazel, node_modules/@angular/build-tooling/bazel/http-server/index.bzl, node_modules/@angular/build-tooling/bazel/http-server/main.ts of angular source code.

all can not work, still is 4200 port.

anlexn@DOOR:~/workspace/github.com/anlexN/angular$ yarn docs
yarn run v1.22.22
$ [[ -n $CI ]] && echo 'Cannot run this yarn script on CI' && exit 1 || yarn ibazel run //adev:serve
/bin/sh: 1: [[: not found
$ /home/anlexn/workspace/github.com/anlexN/angular/node_modules/.bin/ibazel run //adev:serve
iBazel [10:09AM]: Querying for files to watch...
iBazel [10:09AM]: Error evaluating symbolic links for source file: lstat /home/anlexn/workspace/github.com/anlexN/angular/adev/shared-docs/components/select/public_api.ts: no such file or directory
iBazel [10:09AM]: Running //adev:serve
Loading:
Loading: 0 packages loaded
Analyzing: target //adev:serve (0 packages loaded, 0 targets configured)
Analyzing: target //adev:serve (1 packages loaded, 243 targets configured)
Analyzing: target //adev:serve (1 packages loaded, 2489 targets configured)
Analyzing: target //adev:serve (1 packages loaded, 2710 targets configured)
Analyzing: target //adev:serve (1 packages loaded, 2787 targets configured)
INFO: Analyzed target //adev:serve (1 packages loaded, 2791 targets configured).

INFO: Found 1 target...




INFO: Elapsed time: 5.402s

INFO: 0 processes.

INFO: Build completed successfully, 0 total actions
INFO: Build completed successfully, 0 total actions
iBazel [10:09AM]: Launching with notifications
INFO: Analyzed target //adev:serve (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //adev:serve up-to-date:
  dist/bin/adev/serve_launcher.sh
  dist/bin/adev/serve
INFO: Elapsed time: 7.240s, Critical Path: 2.10s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
iBazel [10:09AM]: Starting...

################################################################################
# Did you know iBazel can invoke programs like Gazelle, buildozer, and         #
# other BUILD file generators for you automatically based on bazel output?     #
# Documentation at: https://github.com/bazelbuild/bazel-watcher#output-runner  #
################################################################################

[Browsersync] Access URLs:
 ----------------------------
 Local: http://localhost:4200
 ----------------------------
    UI: http://localhost:3001
 ----------------------------
[Browsersync] Serving files from: ./

angular repo

I am reviewing angular source code.

I have searched in the google and chatgpt, there have some explanations. but I want to make sure 100%. so I want to talk about this question.

I have searched in the stackoverflow, but have no explanations.

I want to change Local: http://localhost:4200 to Local: http://localhost:4242.


Solution

  • Edit the adev/BUILD.bazel file and add the port argument:

    http_server(
        name = "serve",
        additional_root_paths = [
            "angular/adev/build/browser",
        ],
        enable_dev_ui = True,
        relax_cors = True,
        deps = [":build"],
        port = 54321, # Here
    )