dart2js试图编译css?

时间:2016-05-18 15:50:19

标签: angular dart dart-pub dart2js

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

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

me@my_computer$ pub build

Pub Build Output:

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也没有任何问题。

1 个答案:

答案 0 :(得分:3)

我会尝试排除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