-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload source maps during prod build
- Loading branch information
1 parent
6ba4967
commit 6bb808f
Showing
4 changed files
with
52 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
// import { unlinkSync } from 'fs' | ||
import { execSync } from 'child_process' | ||
|
||
const main = () => { | ||
if (process.env.VERCEL_ENV === 'development') { | ||
return | ||
} | ||
|
||
const LATEST_SHA = execSync('git rev-parse HEAD').toString().trim() | ||
const PATH_PREFIX = 'https://developer.hashicorp.com/_next/static/' | ||
const SERVICE = 'developer.hashicorp.com' | ||
|
||
const DATADOG_API_KEY = process.env.DD_API_KEY | ||
|
||
try { | ||
const status = execSync( | ||
`DATADOG_API_KEY=${DATADOG_API_KEY} npx @datadog/datadog-ci sourcemaps upload .next/static/ --service=${SERVICE} --release-version=${LATEST_SHA} --minified-path-prefix=${PATH_PREFIX}` | ||
) | ||
|
||
status | ||
.toString() | ||
.split('\n') | ||
.forEach((line) => { | ||
console.log(line) | ||
}) | ||
|
||
console.log('Source maps uploaded successfully') | ||
|
||
// Delete the source map file | ||
// unlinkSync('.next/static/your-source-map-file.js.map') | ||
|
||
console.log('Source map deleted successfully') | ||
} catch (error) { | ||
console.error(error) | ||
|
||
console.log('Failed to upload source maps') | ||
} | ||
} | ||
|
||
main() |
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