dart - 如何使用Dart包部署Dart Web应用程序?

标签 dart dart2js

考虑以下dart网络应用程序:

import "dart:html";
// assume this is a custom library hosted somewhere on github, i.e. 
// there is a pubspec.yaml entry
//
// dependencies:
//    my_hello:
//      git: http://github.com/foo/my_hello.git
//
import "package:my_hello/my_hello.dart" as hello;

main() {
  query("#message").innerHtml = hello.message;
}

如何将其部署在Web服务器上的某个位置(例如github页面),以便可以在Dartium中用作基于dart的Web应用程序?
  • 是否必须在Web服务器上创建目录packages
  • 我是否必须将my_hello.dart包复制到Web服务器?
    packages/my_hello/...
    或者Dartium是否能够通过给定pubspec.yaml来解决依赖关系?
  • 最佳答案

    目前,您需要部署packages文件夹以及代码。 Dartium不使用pubspec.yaml
    当前正在进行中的dart2dart工具,其功能与dart2js类似-摇树,缩小代码并将所有代码合并到单个可部署的源文件中。有关说明,请参见此dartbug issue,有关Google网上论坛,请参见此recent discussion

    这很可能构成pub deploy方案的一部分,该方案将用于打包您的应用程序以在Web服务器上进行部署。

    另请参阅:what could be a deployment strategy with pubspec on dart
    和:Creating a Javascript deployment set from Dart2js output

    更新:目前正在处理Dartbug 6006,并说它的工作方式如下:

    It'll copy everything in "web" into a deploy directory, run dart2dart and dart2js on all the entrypoints, and clean up the Dart source files. This will produce a directory that can be served without any additional steps.

    关于dart - 如何使用Dart包部署Dart Web应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15242399/

    相关文章:

    dart - 动画 Controller vsync 无法将 'this' 识别为有效表达式

    javascript - 您如何将Polymer用作dart用作javascript?

    requirejs - Dart2js : Is it possible to start Root Isolate from Javascript?

    firebase - Firestore映射到StreamBuilder => ListView.Builder

    Flutter 卡住,使用联合/密封类时如何返回值并停止执行函数

    flutter - 在 Dart 中将 int 转换为 Uint8

    dart - 如何使用webdev构建两个版本?

    javascript - AngularDart 4-5 变更检测与 Angular 5 变更检测有何不同?

    google-maps - 在google_maps包上使用minify时的Dart2JS编译器异常

    namespaces - 角达特 : Namespace of route names hierarchical too?