Pergunta

Consider the following dart web app:

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;
}

How to deploy it somewhere on a web server (for example as github pages), such that it can be used as dart based web app in Dartium?

  1. Do I have to create a directory packages on the web server?
  2. Do I have to copy the package my_hello.dart to the web server?

    packages/my_hello/...

    Or is Dartium able to resolve the dependencies given a pubspec.yaml ?

Foi útil?

Solução

At the moment, you need to deploy the packages folders, along with your code. Dartium doesn't use the pubspec.yaml

Currently in progress, there is a dart2dart tool, which does a similar thing to dart2js - tree shaking, minification, and bringing all the code into a single deployable source file. See this dartbug issue for instruction and this recent discussion on google groups.

This will likely form part of the pub deploy scenario, which will be used to package your app for deployment on a web server.

See also: what could be a deployment strategy with pubspec on dart and: Creating a Javascript deployment set from Dart2js output

Update: Dartbug 6006 is being worked on at the moment, and says that it work like the following:

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.

Outras dicas

Use:

$ pub build [--no-minify]

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.

From a Seth Ladd's post on Google+ (no longer available).

Personally I've been using rsync since its simple and fast

cd web
rsync -RLr . ../../deploy/

Here's a utiliy script which copies the packages a web app depends on to a deployment directory - see Gist

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top