dart2js 试图编译 css?

dart2js attempting to compile css?

看起来 dart2js 正在尝试编译 bootstrap 的 css 文件。我已经尝试 google 这个问题,但我找不到任何有用的东西。我想那是因为我不确定我应该用谷歌搜索什么。

我的上一个项目很顺利,因为我在这个项目中使用了所有相同的库,所以我只是复制了 pubspec.yaml

me@my_computer$ pub build

Pub 构建输出:

Loading source assets... 
Loading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smoke/src/default_transformer transformerLoading angular2/transform/codegen, dart_to_js_script_rewriter, observe and smoke/src/default_transformer transformers... 
Loading angular2 transformers... (3.4s) 
Building progress_viewer... 
[Info from Dart2JS]:
Compiling progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.min.css.dart...
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.dart:1:9:
Expected ';' after this.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.min.css.dart;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.dart:1:44:
Can't have modifier '.3' here.
Try replacing modifier '.3' with 'var', 'final', or a type.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.min.css.dart;
                                           ^^
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.dart:1:70:
Can't have modifier '.' here.
Try replacing modifier '.' with 'var', 'final', or a type.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.min.css.dart;
                                                                     ^
[Warning from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.dart:
Could not find 'main'.
Try adding a method named 'main' to your program.
[Info from Dart2JS]:
Took 0:00:01.104162 to compile progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.min.css.dart.
[Info from Dart2JS]:
Compiling progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.min.css.shim.dart...
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.shim.dart:1:9:
Expected ';' after this.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.min.css.shim.dart;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.shim.dart:1:44:
Can't have modifier '.3' here.
Try replacing modifier '.3' with 'var', 'final', or a type.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.min.css.shim.dart;
                                           ^^
[Warning from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.min.css.shim.dart:
Could not find 'main'.
Try adding a method named 'main' to your program.
[Info from Dart2JS]:
Took 0:00:00.503648 to compile progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.min.css.shim.dart.
[Info from Dart2JS]:
Compiling progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.css.dart...
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.dart:1:9:
Expected ';' after this.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.css.dart;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.dart:1:44:
Can't have modifier '.3' here.
Try replacing modifier '.3' with 'var', 'final', or a type.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.css.dart;
                                           ^^
[Warning from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.dart:
Could not find 'main'.
Try adding a method named 'main' to your program.
[Info from Dart2JS]:
Took 0:00:00.401814 to compile progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.css.dart.
[Info from Dart2JS]:
Compiling progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.css.shim.dart...
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.shim.dart:1:9:
Expected ';' after this.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.css.shim.dart;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.shim.dart:1:44:
Can't have modifier '.3' here.
Try replacing modifier '.3' with 'var', 'final', or a type.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.css.shim.dart;
                                           ^^
[Error from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.shim.dart:1:71:
Can't have modifier '.' here.
Try replacing modifier '.' with 'var', 'final', or a type.
library progress_viewer_web_css_bootstrap_3.3.6_css_bootstrap.css.shim.dart;
                                                                      ^
[Warning from Dart2JS]:
web/css/bootstrap-3.3.6/css/bootstrap.css.shim.dart:
Could not find 'main'.
Try adding a method named 'main' to your program.
[Info from Dart2JS]:
Took 0:00:00.383610 to compile progress_viewer|web/css/bootstrap-3.3.6/css/bootstrap.css.shim.dart.
[Info from Dart2JS]:
Compiling progress_viewer|web/main.dart...
[Info from Dart2JS]:
Took 0:00:11.785265 to compile progress_viewer|web/main.dart.
Build failed.

我的pubspec.yaml:

这基本上是在 angular2 入门中使用的 page,但是添加了平台指令。

name: progress_viewer
description: Just messing with some stuff
version: 0.1.0
environment:
  sdk: '>=1.13.0 <2.0.0'
dependencies:
  angular2: 2.0.0-beta.17
  browser: ^0.10.0
  dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
    entry_points: web/main.dart
    platform_directives:
    - package:angular2/common.dart#CORE_DIRECTIVES
    - package:angular2/common.dart#FORM_DIRECTIVES
- dart_to_js_script_rewriter

我的目录布局:

我只使用 dart 几个星期,但我遵循了他们的目录布局 guide

project_folder/
|- web/
|  |- index.html
|  |- main.dart
|  |- css/
|     |- bootstrap-3.3.6/
|        |- css/
|        |  |- bootstrap.css
|        |  |- bootstrap.min.css
|        |
|        |- fonts/
|           |- glyphicons-halflinks-regular.eot
|           |- glyphicons-halflinks-regular.svg
|           |- glyphicons-halflinks-regular.ttf
|           |- glyphicons-halflinks-regular.woff
|           |- glyphicons-halflinks-regular.woff2
|
|- lib/
|  |- some_component/
|  |  |- some.component.dart
|  |  |- some.component.html
|  |  |- ...( possible other files e.g. .css )
|  |
|  |- ...( other components )
|  
|- pubspec.yaml
|
|- ...( other files )

我已经列出了 bootstrap-3.3.6 目录下的所有内容。没有这样的文件 web/css/bootstrap-3.3.6/css/bootstrap.min.css.dartweb/css/bootstrap-3.3.6/css/bootstrap.min.css.shim.dart

尽管 pub build 似乎不适用于此项目,但 pub serve 完全没有问题。

我会尝试排除 Angular2 转换器的 web/css 目录:

transformers:
- angular2:
    $exclude: ['web/css/**']
    entry_points: web/main.dart
    platform_directives:
    - package:angular2/common.dart#CORE_DIRECTIVES
    - package:angular2/common.dart#FORM_DIRECTIVES
- dart_to_js_script_rewriter