pub serve 找不到 lib 下的文件
pub serve not finding files under lib
我正在使用 Angular 版本 2 的开发人员预览进行测试,并使用 pub serve
提供它
我想建立一个约定来在 /lib/ 中构建我的文件,如下所示:
└── project/lib/root
├── root.css
├── root.dart
└── root.html
└── project/web/
├── index.html
└── index.dart
在我的 /web/index.dart 文件中,我成功地能够从 root.dart
初始化 @View 和 @Component
但是,当我通过 pub serve 在 Dartium 中预览时 - 我似乎无法提供服务 /lib/root/root。html
@Component(
selector: 'jroot'
)
@View(
templateUrl: '../../lib/root/root.html',
directives: const [If]
)
class Root {
String content = 'Root - This is the entry point to the component';
List<Times> list;
Root(){
print('RootComponent Init');
}
}
Dartium 控制台:
GET http://localhost:8080/lib/root/root.html 404 (Not Found)
我一直在阅读此处关于聚合物的文档,其中指出:
"Non-Dart files under lib must use relative paths to import assets under lib:"
https://www.dartlang.org/polymer/app-directories.html
<!-- lib/a5/a6/a6.html imports lib/a4.html -->
<link rel="import" href="../../a4.html">
运行 一个 python 简单的网络服务器似乎可以工作,所以问题出在发布服务器上:
python -m SimpleHTTPServer
问题: configure pub 如何处理来自 lib 文件夹的嵌套 html 文件?
确保您的 pubspec.yaml 变压器上有正确的入口点:
name: 'project'
version: 0.0.1
dependencies:
angular2: '2.0.0-alpha.23'
browser: any
transformers:
- angular2:
entry_points:
- web/index.dart //this
reflection_entry_points:
- web/index.dart //this
那么我认为这应该可行
templateUrl: 'packages/project/root/root.html',
或者只是
templateUrl: 'root.html',
我正在使用 Angular 版本 2 的开发人员预览进行测试,并使用 pub serve
提供它我想建立一个约定来在 /lib/ 中构建我的文件,如下所示:
└── project/lib/root
├── root.css
├── root.dart
└── root.html
└── project/web/
├── index.html
└── index.dart
在我的 /web/index.dart 文件中,我成功地能够从 root.dart
初始化 @View 和 @Component但是,当我通过 pub serve 在 Dartium 中预览时 - 我似乎无法提供服务 /lib/root/root。html
@Component(
selector: 'jroot'
)
@View(
templateUrl: '../../lib/root/root.html',
directives: const [If]
)
class Root {
String content = 'Root - This is the entry point to the component';
List<Times> list;
Root(){
print('RootComponent Init');
}
}
Dartium 控制台:
GET http://localhost:8080/lib/root/root.html 404 (Not Found)
我一直在阅读此处关于聚合物的文档,其中指出:
"Non-Dart files under lib must use relative paths to import assets under lib:"
https://www.dartlang.org/polymer/app-directories.html
<!-- lib/a5/a6/a6.html imports lib/a4.html -->
<link rel="import" href="../../a4.html">
运行 一个 python 简单的网络服务器似乎可以工作,所以问题出在发布服务器上:
python -m SimpleHTTPServer
问题: configure pub 如何处理来自 lib 文件夹的嵌套 html 文件?
确保您的 pubspec.yaml 变压器上有正确的入口点:
name: 'project'
version: 0.0.1
dependencies:
angular2: '2.0.0-alpha.23'
browser: any
transformers:
- angular2:
entry_points:
- web/index.dart //this
reflection_entry_points:
- web/index.dart //this
那么我认为这应该可行
templateUrl: 'packages/project/root/root.html',
或者只是
templateUrl: 'root.html',