pub不提供lib下的文件

时间:2015-05-17 14:49:33

标签: dart angular

我正在测试Angular Version 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)

我一直在阅读聚合物的文件,其中说明:

  

“lib下的非Dart文件必须使用相对路径导入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简单的Web服务器似乎有效,所以问题在于pub serve:

python -m SimpleHTTPServer

问题:如何使用配置pub来处理lib文件夹中的嵌套html文件?

1 个答案:

答案 0 :(得分:2)

确保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',