简体   繁体   中英

(Ionic / Capacitor) --> No TypeScript source-map with build on Android device

I am currently on a project developed width Ionic4 and Capacitor.

I want, when building my project on a smartphone (Android), get the source-map files ".ts". For now, I only have the source-map files ".scss" and ".html".

Here are all the tests of build that I tried

package.json

"scripts": {

   "android": "npx cap copy && npx cap open android", // And sync if necessary


   "build_1: "ng build && npm run android",
   "build_2: "ng build --sourceMap && npm run android",

   "build_3: "ionic build && npm run android",
   "build_4: "ionic build --source-map && npm run android",
}

I also tried to add this

"config": {
   "ionic_generate_source_map": "true",
   "ionic_source_map_type": "inline-source-map" // Or eval-source-map
}

Then, finding no solution, I tried webpack.

Inside package.json

"config": {
   "ionic_webpack": "./webpack.config.js"
}

Inside webpack.config.js

const process = require('process');
const useDefaultConfig = require('@ionic/app-scripts/config/webpack.config.js');

const env = process.env.IONIC_ENV;

if (env === 'dev' || env === 'development') {
   useDefaultConfig[env].devtool = 'inline-source-map';
}

module.exports = () => useDefaultConfig;

Then, once the compilation is finished, I launch the project with Android Studio.

I inspect the sources with Chrome inspect and I only get the sources of the "html" and "scss" files, but not "TypeScript".

Does anyone have a magic idea ?

Config info

  • Ionic:

    • Ionic CLI : 5.2.4
    • Ionic Framework : @ionic/angular 4.7.4
    • @angular-devkit/build-angular : 0.13.9
    • @angular-devkit/schematics : 7.3.9
    • @angular/cli : 7.3.9
    • @ionic/angular-toolkit : 1.4.1
  • Capacitor:

    • Capacitor CLI : 1.1.1
    • @capacitor/core : 1.1.1
  • Cordova:

    • Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
    • Cordova Platforms : none
    • Cordova Plugins : no whitelisted plugins (0 plugins total)
  • Utility:

    • cordova-res : not installed
    • native-run : 0.2.7
  • System:

    • Android SDK Tools : 26.1.1 (C:\\Users\\xxxxx\\AppData\\Local\\Android\\Sdk)
    • NodeJS : v10.15.3 (C:\\Program Files\\nodejs\\node.exe)
    • npm : 6.10.3
    • OS : Windows 10

tsconfig.json

...
"lib": ["dom", "es6"],
"module": "es6",
"target": "es6",
"sourceMap": true
...

I found a solution to my problem.

I use the command npm run build_r define in package.json

scripts: {
    "build_r": "ionic capacitor run android --source-map --livereload"
}

below which allows me to access the source-map

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