This repository has been archived by the owner on May 1, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sourcemaps): copy for prod and dev
- Loading branch information
Showing
1 changed file
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,7 @@ import * as Constants from './constants'; | |
import { copyFileAsync, getBooleanPropertyValue, readDirAsync, unlinkAsync } from './helpers'; | ||
import { BuildContext } from './interfaces'; | ||
|
||
export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> { | ||
if (getBooleanPropertyValue(Constants.ENV_VAR_GENERATE_SOURCE_MAP)) { | ||
// keep the source maps and just return | ||
return Promise.resolve([]); | ||
} | ||
function copySourcemaps(context: BuildContext, shouldPurge: boolean) { | ||
return readDirAsync(context.buildDir).then((fileNames) => { | ||
const sourceMaps = fileNames.filter(fileName => fileName.endsWith('.map')); | ||
const fullPaths = sourceMaps.map(sourceMap => join(context.buildDir, sourceMap)); | ||
|
@@ -18,14 +14,25 @@ export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> { | |
if (copyBeforePurge) { | ||
mkdirpSync(context.sourcemapDir) | ||
const relativeTo = relative(fullPath, context.sourcemapDir) | ||
const fileName = basename(fullPath) | ||
promises.push(copyFileAsync(fullPath, join(context.sourcemapDir, fileName)).then(() => { | ||
return unlinkAsync(fullPath) | ||
})) | ||
} else { | ||
const fileName = basename(fullPath); | ||
if (fileName.indexOf('vendor.js') < 0) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ippeiukai
|
||
promises.push(copyFileAsync(fullPath, join(context.sourcemapDir, fileName))); | ||
} | ||
} | ||
|
||
if (shouldPurge) { | ||
promises.push(unlinkAsync(fullPath)) | ||
} | ||
} | ||
return Promise.all(promises); | ||
}); | ||
} | ||
|
||
export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> { | ||
if (getBooleanPropertyValue(Constants.ENV_VAR_GENERATE_SOURCE_MAP)) { | ||
// keep the source maps and just return | ||
return copySourcemaps(context, false); | ||
} | ||
|
||
return copySourcemaps(context, true); | ||
} |
But why? Why not copy the vendor.js sourcemap?