Dart包管理通过dart2js [英] Dart Package Management via dart2js

查看:246
本文介绍了Dart包管理通过dart2js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Dart及其依赖管理员 pub ,我很难在这里看到forest through the trees。



说我想在我的项目中使用 Polymer.dart 。所以,在我的项目根目录下,我创建以下 pubspec.yaml

  name:test_dart 
description:一个示例Web应用程序
dependencies:
browser:any
polymer:> = 0.9.0& 0.10.0

然后运行 pub get ,转到 pub repo并获取浏览器聚合物我指定的依赖项。然后在我的项目根目录中创建一个 packages 目录,这意味着我有一个项目:

  MyDartProject / 
pubspec.yaml
myapp.dart
packages /
browser /
...
..现在我开始编写我的Dart网络应用程序(<$ c $

c> myapp.dart
),它将引用各种Polymer和 browser types / functions / etc。



当我完成后,我想创建一个名为 myapp.js



根据 dart2js docs ,我需要运行类似:

  dart2js --out = myapp.js --package-root = ??? myapp.dart 

如何将所有浏览器

解决方案

现在有一个pub build选项。



http://pub.dartlang.org/doc /pub-build.html


准备好部署网络应用程序时,使用pub build。当你运行
pub build时,它会生成当前软件包的资产,以及所有的
它的依赖,将它们放入一个名为build的新目录。




  $ cd〜/ dart / helloworld 
$ pub build
建立helloworld ......
5个文件!

如果构建目录已经存在,pub build会删除它,然后再次创建它。



这应该做你在这里以后的一切。你也可以从IDE中通过右键点击pubspec.yaml文件并选择pub build来启动它。



编辑:你也应该看到zoechi的答案中的链接。


I'm learning Dart and its dependency manager pub and am having a tough time seeing the "forest through the trees" here.

Say I want to use Polymer.dart in my project. So, in my project root, I create the following pubspec.yaml:

name: test_dart
description: A sample web application
dependencies:
    browser: any
    polymer: ">=0.9.0 <0.10.0"

I then run pub get, which goes to the pub repo and fetches the browser and polymer dependencies that I've specified. It then creates a packages directory in my project root, which now means I have a project that looks like:

MyDartProject/
    pubspec.yaml
    myapp.dart
    packages/
        browser/
            ...
        ...all the packages that ship with Polymer

Now I start coding my Dart web app (myapp.dart), which will references various Polymer and browser types/functions/etc. in its source code.

When I'm all done, I want to create a JavaScript file called myapp.js.

According to the dart2js docs, I need to run something like:

dart2js --out=myapp.js --package-root=??? myapp.dart

How do I include all the browser & polymer packages on the buildpath?

解决方案

There is a "pub build" option now.

http://pub.dartlang.org/doc/pub-build.html

Use pub build when you’re ready to deploy your web app. When you run pub build, it generates the assets for the current package and all of its dependencies, putting them into a new directory named build.

$ cd ~/dart/helloworld
$ pub build
Building helloworld......
Built 5 files!

If the build directory already exists, pub build deletes it and then creates it again.

That should do everything you are after here. You can also launch it from the IDE by right clicking on the pubspec.yaml file and choose "pub build"

EDIT: You should also see the links in zoechi's answer.

这篇关于Dart包管理通过dart2js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆