Question

Dart's Web UI performs a compile step which puts the generated files into an "out" folder. I can't figure out how to get an image to be placed in that out folder, though. Does anyone know how?

I have the images in the web folder in a folder called img, although I've also tried putting them directly in web. Should I create a top level folder named resources and put them in there instead?

Was it helpful?

Solution

I had the same problem, and have almost solved it by updating my build.dart to include a copy of the img folder into the out folder.

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

// Ref: http://www.dartlang.org/articles/dart-web-components/tools.html
// Actually ... https://github.com/sethladd/dart-web-components-tests/blob/master/build.dart
main() {
  var args = new List.from(new Options().arguments);
//  args.addAll(['--', '--no-rewrite-urls']);

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

  dwc
    .then((_) => Process.run('cp', ['-fR', 'web/img', 'web/out']));
}

In the above I've added a command to run "cp" (I'm on a Mac) of web/img to web/out.

I say almost solved it because those image in the img folder also end up being copied directly into the out folder as well as out/img, which isn't ideal but doesn't harm anything for me just now. I believe these extra copies are from build.dart being triggered by the copy, haven't found a way to stop this yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top