dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
212 stars 75 forks source link

dart.vm.product is not set to true in --release builds #1739

Open eseidel opened 2 years ago

eseidel commented 2 years ago

Flutter seems to have landed on using dart.vm.product to indicate release mode.

https://api.flutter.dev/flutter/foundation/kReleaseMode-constant.html

How Flutter sets it: https://github.com/flutter/flutter/blob/b7c500fc6bf04e44156722cd053020595d1fbd35/packages/flutter_tools/lib/src/compile.dart#L197

I was looking for something similar for "dart web" builds, and failed to find such. Would be nice if the Flutter way worked for webdev build --release or at least if some way worked. :)

eseidel commented 2 years ago

Adding a build.yaml with:

targets:
  $default:
    builders:
      build_web_compilers:entrypoint:
        release_options:
          dart2js_args:
           - '-Ddart.vm.product=true'

appears to be the necessary magic. :)