如何配置 angular-cli 来创建内联源映射? [英] How to configure angular-cli to create inline sourcemaps?

查看:29
本文介绍了如何配置 angular-cli 来创建内联源映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

angular.json 仅提供打开/关闭源映射生成的选项,但默认情况下它位于单独的文件中.

angular.json only gives the option to turn on/off sourcemap generation but by default it's in separate files.

tsconfig.json 也提供了 inlineSources 选项,但它被 angular-cli 忽略.

tsconfig.json gives also the inlineSources option but it's ignored by angular-cli.

有没有办法告诉 angular-cli 在 .js 中编写源映射?

Is there a way to tell angular-cli to write the source maps inside the .js?

推荐答案

对于可能关心的人,这里是我实现的方法,用于在 Android 设备上启用带有源映射支持的调试

To whom it may concern, here is the approach I implemented to enable debugging with source maps support on Android devices

  • install ngx-build-plus by running npx ng add ngx-build-plus
    This will install the required npm package and update angular.json as required For more details please see https://github.com/manfredsteyer/ngx-build-plus
  • create new file build-customization-plugin.js in the project root directory and add the below content in this file
var merge = require('webpack-merge');

exports.default = {
    config: function (cfg) {
        const strategy = merge.strategy({
            'devtool': 'replace',
        });

        return strategy(cfg, {
            devtool: 'inline-source-map'
        });
    }
}

  • 从根目录运行 ng build --eval-source-map --plugin ~build-customization-plugin.js 以使用源映射构建项目以在 Android 设备上进行调试
    • run ng build --eval-source-map --plugin ~build-customization-plugin.js from the root directory to build the project with source maps to debug on Android devices
    • 这是一种比我在之前的端口中描述的更改 angular/cli 源更好的方法:)

      This is a better approach then changing angular/cli source as I described in a previous port :)

      这篇关于如何配置 angular-cli 来创建内联源映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆