首页 > 解决方案 > 使用 bazel 在角度应用程序中指定基本 href

问题描述

我正在尝试将 bazel 添加到有角度的应用程序中,但在尝试将应用程序提供给特定 url 时仍然遇到问题。我之前有的是:

ng serve --host 0.0.0.0 --public-host http://localhost:4200/ --poll=500 --base-href /app/ --serve-path /app/

我想用 bazel 做同样的事情,但我做不到。在 ts_devserver 我做了:

ts_devserver(
    name = "devserver",
    # Serve src/example/index.html at /index.html
    additional_root_paths = ["src/example"],
    # Run the program from the development version of the main
    entry_module = "project/src/main.dev",
    # These scripts will be included in the JS bundle after require.js
    # They should have only named UMD modules, or require.js will throw.
    scripts = [
        "@npm//:node_modules/tslib/tslib.js",
        ":rxjs_umd_modules",
        # We are manaully adding the bazel generated named-UMD date-fns bundle here as
        # named-UMD bundles for non-APF npm packages are not yet automatically added.
        # This file is generated by the npm_umd_bundle @npm//date-fns:date-fns__umd
        # rule that is setup by yarn_install.
        # "@npm//date-fns:date-fns.umd.js",
    ],
    port = 4200,
    serving_path = "/app/",
    # Serve these files in addition to the JavaScript bundle
    static_files = _ASSETS + [
        ":inject_scripts_for_dev",
    ],
    # Tell Bazel to build the sources first
    deps = ["//src"],
)

在我的 index.html 我有<base href="/app/" />

缺少什么配置,以便我可以在 localhost/app 上为我的应用程序提供服务?

谢谢你。

标签: angularbazel

解决方案


推荐阅读