4

build.dart is run by Dart Editor whenever a file changes. Many developers use build.dart to compile their Web UI apps. How can I run other commands after Web UI compiler finishes?

Seth Ladd
  • 112,095
  • 66
  • 196
  • 279

1 Answers1

6

The build() function returns a Future. You can register a callback to run after build() runs.

Here is an example:

import 'package:web_ui/component_build.dart';
import 'dart:io';
import 'dart:async';

void main() {
  var args = new List.from(new Options().arguments);
  args.addAll(['--', '--no-rewrite-urls']);

  Future dwc = build(args, ['web/clock_page.html']);

  dwc
    .then((_) => Process.run('cp', ['packages/browser/dart.js', 'web/out/dart.js']))
    .then((_) => Process.run('cp', ['App.css', 'out']));
}

Learn more:

Seth Ladd
  • 112,095
  • 66
  • 196
  • 279