Brian Slesinsky
Brian Slesinsky

Reputation: 2886

How do I enable source map generation when using "webdev build"?

When using Dart 2 and the webdev build command, I get a build/main.dart.js file. At the end of this file, there is a comment pointing the source map:

//# sourceMappingURL=main.dart.js.map

However, this file doesn't exist. How do I get the .map file and Dart source files to show up in the build directory so that Chrome devtools will see them?

Upvotes: 4

Views: 1636

Answers (3)

navid
navid

Reputation: 1398

I was able to use the generated file in .dart_tool\build\generated\{PROJECT}\web\main.dart.js.map as source map of my main.dart.js. Just copy the file to the location of web build directory, then reload page.

(webdev: v2.7.10)

Upvotes: 1

jumperchen
jumperchen

Reputation: 1473

According to the document of webdev build, you should use webdev build --no-release instead. (but this will use DDC compiler instead.)

Update info: By default, webdev build in release mode will remove all *.js.map file, so you can put a build.yaml file in your project root folder to deactivate dart cleanup source.

For example, (build.yaml file) targets: $default: builders: build_web_compilers|dart_source_cleanup: release_options: enabled: false

Upvotes: 3

Michael Maroszek
Michael Maroszek

Reputation: 1

I don't have an exact answer for your question. I ended up calling dart2js manually to get unminified code.

dart2js -o app.js web/app.dart

Upvotes: 0

Related Questions