Sourcemaps appear to be broken when uglify/--prod task is used. #1235
Description
Short description of the problem:
For info, the below behaviour of generating production sourcemaps worked correctly in v1.3.12 so I feel like this is a potential regression or bug.
When setting ionic_generate_source_map
to true and running ionic build --prod
, the sourcemaps produced seem to be broken as they are significantly different when compared to ionic build
based sourcemaps with several base64 chunks and random blocks of code seemingly in the wrong position. When checking the sourcemaps with Raygun The same part of the sourcemap always returns when querying different lines/columns. The sourceMappingURL
is also missing on main.js & vendor.js
I believe the problem occurs when the uglifyjs task is ran as it doesn't occur on ionic build
for example. I tried to provide my own config based on a modified default config to uglifyjs with sourcemaps set to true to no effect.
Also, when setting ionic_generate_source_map
to true, vendor.js.map isn't copied over to the sourcemaps folder.
The reason for needing sourcemaps based on --prod code is for error tracking.
I've spent a few hours looking at the app-scripts workflow but couldn't quite work out where the uglifyjs sourcemap options were getting added but I'd be happy to look more into this if I could get some guidance and help as to where to look.
There are some similar-ish tickets to my one but they refer to different aspects of sourcemaps, eg the mappingurl being an absolute path, not completely missing so I don't think this is a duplicate.
Thanks.
What behavior are you expecting?
To summarise, I'd expect when running the build task with --prod
flag:
- The
//# sourceMappingURL=main.js.map
to be present in main.js, - The
//# sourceMappingURL=vendor.js.map
to be present in vendor.js, vendor.js.map
should be copied into the.sourcemaps
directory,- The sourcemaps to be generating correctly.
Steps to reproduce:
- Set ionic_generate_source_map to true in package.json
- Run
ionic build
and save sourcemaps somewhere, - Run
ionic build --prod
and compare sourcemaps.
Which @ionic/app-scripts version are you using?
2.1.4