How to keep sourcemaps after production build?
Right now, my command looks like this:
"build-prod": "ng build --app=release -prod && cp -R lang dist"
I tried changing it to:
ng build --app=release --sourceMap=true -prod && cp -R lang dist
but nothing changed.
If I do:
ng build --sourcemap
I get sourcemaps but then I get index.html instead of index.prod.html.
Is it possible to edit the first command to build sourcemap files?
this is my tsconfig.json
file:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
To build your application for production, use the build command. By default, this command uses the production build configuration. This command creates a dist folder in the application root directory with all the files that a hosting service needs for serving your application.
The source map explorer determines which file each byte in your minified code came from. It shows you an interactive tree-map visualization to help you debug where all the code is coming from. Before starting I would like to recommend this video from Stephen Fluin, angular team member.
You should edit your angular.json
like this
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false, // change to true
Then run
ng build --prod
But I wouldnt recommend you turn on source map in production because it will increase a bundle size
you can try
ng build --prod --source-map=true|false
angular.io/cli/build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With