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?
packages
on the web server?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
?
You have the option of using Dart web with a higher-level web app framework. Many apps that support web plus mobile or desktop are built using Flutter and Flutter web support.
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.
Use:
$ pub build [--no-minify]
Use
pub build
when you’re ready to deploy your web app. When you runpub 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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With