compile method
Implementation
Future<void> compile() async {
if (!component.buildInitialize) {
return;
}
var _buildDir = Directory(getBuildDir());
var packagesDir = Directory("${getBuildDir()}/packages");
if (!(await _buildDir.exists())) {
await _buildDir.create();
}
if (!(await packagesDir.exists())) {
print("created ${packagesDir.path}");
await packagesDir.create();
}
var depsFile = File("${getBuildDir()}/"
"packages/build_web_compilers/src/dev_compiler_stack_trace/stack_trace_mapper.dart.js.deps");
var mapFile = File(
"${getBuildDir()}/packages/build_web_compilers/src/dev_compiler_stack_trace/stack_trace_mapper.dart.js.map");
var manifest = File("${getBuildDir()}/.build.manifest");
manifest.writeAsString(".packages");
depsFile.createSync(recursive: true);
mapFile.createSync(recursive: true);
dirsCreated.complete(true);
await depsFile.writeAsString(_deps, mode: FileMode.write);
await mapFile.writeAsString(_map, mode: FileMode.write);
var args = [
"pub",
"run",
"build_runner",
component.watchChanges ? "watch" : "build",
"--output",
"$buildDir",
"--release",
"--define",
"build_web_compilers:entrypoint=compiler=dartdevc",
"--use-polling-watcher",
"--delete-conflicting-outputs"
];
var process = await Process.start("dart", args,
workingDirectory: component.directory);
var file =
File("${component.directory}logs/${_dateFormat(DateTime.now())}.log");
var exists = file.existsSync();
if (!exists) {
file.createSync(recursive: true);
}
var sink = file.openWrite(mode: FileMode.append);
sink.add(utf8.encode("started dart ${args.join(" ")}\n"));
sink.addStream(process.stdout);
exitCode.complete(await process.exitCode);
sink.add(utf8.encode("Build Completed with $exitCode"));
sink.done;
}