@@ -4,11 +4,7 @@ import * as Constants from './constants';
44import { copyFileAsync , getBooleanPropertyValue , readDirAsync , unlinkAsync } from './helpers' ;
55import { BuildContext } from './interfaces' ;
66
7- export function purgeSourceMapsIfNeeded ( context : BuildContext ) : Promise < any > {
8- if ( getBooleanPropertyValue ( Constants . ENV_VAR_GENERATE_SOURCE_MAP ) ) {
9- // keep the source maps and just return
10- return Promise . resolve ( [ ] ) ;
11- }
7+ function copySourcemaps ( context : BuildContext , shouldPurge : boolean ) {
128 return readDirAsync ( context . buildDir ) . then ( ( fileNames ) => {
139 const sourceMaps = fileNames . filter ( fileName => fileName . endsWith ( '.map' ) ) ;
1410 const fullPaths = sourceMaps . map ( sourceMap => join ( context . buildDir , sourceMap ) ) ;
@@ -18,14 +14,25 @@ export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> {
1814 if ( copyBeforePurge ) {
1915 mkdirpSync ( context . sourcemapDir )
2016 const relativeTo = relative ( fullPath , context . sourcemapDir )
21- const fileName = basename ( fullPath )
22- promises . push ( copyFileAsync ( fullPath , join ( context . sourcemapDir , fileName ) ) . then ( ( ) => {
23- return unlinkAsync ( fullPath )
24- } ) )
25- } else {
17+ const fileName = basename ( fullPath ) ;
18+ if ( fileName . indexOf ( 'vendor.js' ) < 0 ) {
19+ promises . push ( copyFileAsync ( fullPath , join ( context . sourcemapDir , fileName ) ) ) ;
20+ }
21+ }
22+
23+ if ( shouldPurge ) {
2624 promises . push ( unlinkAsync ( fullPath ) )
2725 }
2826 }
2927 return Promise . all ( promises ) ;
3028 } ) ;
3129}
30+
31+ export function purgeSourceMapsIfNeeded ( context : BuildContext ) : Promise < any > {
32+ if ( getBooleanPropertyValue ( Constants . ENV_VAR_GENERATE_SOURCE_MAP ) ) {
33+ // keep the source maps and just return
34+ return copySourcemaps ( context , false ) ;
35+ }
36+
37+ return copySourcemaps ( context , true ) ;
38+ }
0 commit comments