Skip to content

Commit 3569a51

Browse files
committed
Upload source maps to Sentry & drop them from the package
1 parent 8911065 commit 3569a51

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

build-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ rm -r ./tmp || true
3939
# Build the package for this platform
4040
# ------------------------------------------------------------------------
4141

42-
env | grep -E 'npm_|TARGET_'
42+
env | grep -E 'npm_config_|TARGET_'
4343

4444
echo
4545
echo "BUILDING FOR $TARGET_PLATFORM"

pack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ const packageApp = async () => {
5858
// Include package-lock.json, to keep dependencies locked:
5959
'package-lock.json',
6060
// Add the fully bundled source (not normally packaged by npm):
61-
'bundle'
61+
path.join('bundle', 'index.js'),
62+
path.join('bundle', 'error-tracking.js'),
63+
path.join('bundle', 'schema.gql')
6264
].map((extraFile) =>
6365
fs.copy(path.join(__dirname, extraFile), path.join(OUTPUT_DIR, extraFile))
6466
));

package-lock.json

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
},
4949
"devDependencies": {
5050
"@oclif/dev-cli": "^1.19.4",
51+
"@sentry/webpack-plugin": "^1.8.1",
5152
"@types/aws-lambda": "^8.10.15",
5253
"@types/chai": "^4.1.6",
5354
"@types/env-paths": "^1.0.2",

webpack.config.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
const webpack = require('webpack');
22
const path = require('path');
33
const CopyWebpackPlugin = require('copy-webpack-plugin');
4+
const SentryPlugin = require('@sentry/webpack-plugin');
5+
6+
const pjson = require('./package.json');
7+
8+
const OUTPUT_DIR = path.resolve(__dirname, 'bundle');
49

510
module.exports = {
611
entry: {
712
index: './src/index.ts',
813
'error-tracking': './src/error-tracking.ts'
914
},
1015
output: {
11-
path: path.resolve(__dirname, 'bundle'),
16+
path: OUTPUT_DIR,
1217
filename: '[name].js',
1318
libraryTarget: 'commonjs2'
1419
},
@@ -53,7 +58,15 @@ module.exports = {
5358
// Copy Mockttp's schema (read with readFile) into the output directory
5459
new CopyWebpackPlugin([
5560
{ from: path.join('node_modules', 'mockttp', 'dist', 'standalone', 'schema.gql') }
56-
])
61+
]),
62+
// If SENTRY_AUTH_TOKEN is set, upload this sourcemap to Sentry
63+
process.env.SENTRY_AUTH_TOKEN
64+
? new SentryPlugin({
65+
release: pjson.version,
66+
include: OUTPUT_DIR,
67+
validate: true
68+
})
69+
: { apply: () => {} }
5770
],
5871
resolve: {
5972
extensions: [ '.tsx', '.ts', '.js' ]

0 commit comments

Comments
 (0)