简体   繁体   中英

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?

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

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM