1

我正在使用lite-server开发 Angular 应用程序。我有以下项目结构,非常简单:

build/
    foo/
        index.html (references foo.js script)
    bar/
        index.html (references bar.js script)
foo.js
bar.js
bsconfig.json

我想要做的是访问localhost:8000/foo和获取foo/index.html加载foo.js脚本以及访问localhost:8000/bar和获取bar/index.html加载bar.js

我已阅读Browsersync 选项文档并尝试bs-config.json使用配置文件,routes但无法正常工作。

4

2 回答 2

0

您可以将路由添加到服务器对象

routes : {"/foo" : "build/foo", "/bar" : "build/bar" }

您可以将您的 foo.js 和 bar.js 分别放在“foo”和“bar”文件夹下并在本地引用它们,或者将它们留在项目文件夹中并将其引用为“/foo.js”和“/bar.js” "

于 2016-09-07T11:02:07.417 回答
-1

您可以设置base href指向 index.html 文件中的不同文件夹,

  <base href="/foo/">

  <base href="/bar/">

此外,您必须配置从system.config文件中提供主包的位置。

于 2016-08-03T02:45:25.380 回答