Skip to content

Commit 0e7165b

Browse files
author
Luca Forstner
authored
Update bundler plugin documentation for V2 release (#6976)
1 parent ec0e981 commit 0e7165b

File tree

7 files changed

+108
-62
lines changed

7 files changed

+108
-62
lines changed

src/platform-includes/sourcemaps/overview/javascript.vue.mdx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ yarn add @sentry/vite-plugin --dev
1515

1616
### Configuration
1717

18-
Learn more about configuring the plugin in our [Sentry Vite Plugin documentation](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin).
18+
Learn more about configuring the plugin in our [Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).
1919

2020
Example:
2121

2222
```javascript {filename:vite.config.js}
23-
import { fileURLToPath, URL } from "node:url";
2423
import { defineConfig } from "vite";
2524
import vue from "@vitejs/plugin-vue";
2625
import { sentryVitePlugin } from "@sentry/vite-plugin";
@@ -40,25 +39,30 @@ export default defineConfig({
4039

4140
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
4241
// and need `project:releases` and `org:read` scopes
43-
authToken: process.env.SENTRY_AUTH_TOKEN,
42+
authToken: env.SENTRY_AUTH_TOKEN,
4443

4544
sourcemaps: {
4645
// Specify the directory containing build artifacts
47-
assets: "./dist/**",
46+
assets: "./**",
47+
// Don't upload the source maps of dependencies
48+
ignore: ["./node_modules/**"],
4849
},
4950

51+
// Helps troubleshooting - set to false to make plugin less noisy
52+
debug: true,
53+
5054
// Use the following option if you're on an SDK version lower than 7.47.0:
51-
// include: "./dist",
55+
// release: {
56+
// uploadLegacySourcemaps: {
57+
// include: ".",
58+
// ignore: ["node_modules"],
59+
// },
60+
// },
5261

5362
// Optionally uncomment the line below to override automatic release name detection
5463
// release: process.env.RELEASE,
5564
}),
5665
],
57-
resolve: {
58-
alias: {
59-
"@": fileURLToPath(new URL("./src", import.meta.url)),
60-
},
61-
},
6266
});
6367
```
6468

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
`@sentry/sveltekit` will generate and upload source maps automatically, so that errors in Sentry will contain readable stack traces.
22

3-
The SvelteKit SDK uses the [Sentry Vite Plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/packages/vite-plugin) to upload source maps. See the [Manual Configuration](../manual-setup/#configure-source-maps-upload) page and the Sentry [Webpack Vite documentation](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin#configuration) for more details.
3+
The SvelteKit SDK uses the [Sentry Vite Plugin](https://www.npmjs.com/package/@sentry/vite-plugin) to upload source maps. See the [Manual Configuration](../manual-setup/#configure-source-maps-upload) page and the Sentry [Webpack Vite documentation](https://www.npmjs.com/package/@sentry/vite-plugin#options) for more details.

src/platform-includes/sourcemaps/upload/esbuild/javascript.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ yarn add @sentry/esbuild-plugin --dev
1212

1313
## Configure
1414

15-
Learn more about configuring the plugin in our [Sentry esbuild Plugin documentation](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/esbuild-plugin).
15+
Learn more about configuring the plugin in our [Sentry esbuild Plugin documentation](https://www.npmjs.com/package/@sentry/esbuild-plugin).
1616

1717
Example:
1818

1919
```javascript {filename:esbuild.config.js}
2020
const { sentryEsbuildPlugin } = require("@sentry/esbuild-plugin");
2121

2222
require("esbuild").build({
23-
entryPoints: ["./src/index.js"],
24-
outdir: "./dist",
25-
bundle: true,
2623
sourcemap: true, // Source map generation must be turned on
2724
plugins: [
2825
// Put the Sentry esbuild plugin after all other plugins
@@ -32,15 +29,25 @@ require("esbuild").build({
3229

3330
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
3431
// and need `project:releases` and `org:read` scopes
35-
authToken: process.env.SENTRY_AUTH_TOKEN,
32+
authToken: env.SENTRY_AUTH_TOKEN,
3633

3734
sourcemaps: {
3835
// Specify the directory containing build artifacts
39-
assets: "./dist/**",
36+
assets: "./**",
37+
// Don't upload the source maps of dependencies
38+
ignore: ["./node_modules/**"],
4039
},
4140

41+
// Helps troubleshooting - set to false to make plugin less noisy
42+
debug: true,
43+
4244
// Use the following option if you're on an SDK version lower than 7.47.0:
43-
// include: "./dist",
45+
// release: {
46+
// uploadLegacySourcemaps: {
47+
// include: ".",
48+
// ignore: ["node_modules"],
49+
// },
50+
// },
4451

4552
// Optionally uncomment the line below to override automatic release name detection
4653
// release: process.env.RELEASE,

src/platform-includes/sourcemaps/upload/rollup/javascript.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ yarn add @sentry/rollup-plugin --dev
1212

1313
## Configuration
1414

15-
Learn more about configuring the plugin in our [Sentry Rollup Plugin documentation](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/rollup-plugin).
15+
Learn more about configuring the plugin in our [Sentry Rollup Plugin documentation](https://www.npmjs.com/package/@sentry/rollup-plugin).
1616

1717
Example:
1818

1919
```javascript {filename:rollup.config.js}
2020
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
2121

2222
export default {
23-
input: "./src/index.js",
2423
plugins: [
2524
// Put the Sentry rollup plugin after all other plugins
2625
sentryRollupPlugin({
@@ -29,23 +28,32 @@ export default {
2928

3029
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
3130
// and need `project:releases` and `org:read` scopes
32-
authToken: process.env.SENTRY_AUTH_TOKEN,
31+
authToken: env.SENTRY_AUTH_TOKEN,
3332

3433
sourcemaps: {
3534
// Specify the directory containing build artifacts
36-
assets: "./out/**",
35+
assets: "./**",
36+
// Don't upload the source maps of dependencies
37+
ignore: ["./node_modules/**"],
3738
},
3839

40+
// Helps troubleshooting - set to false to make plugin less noisy
41+
debug: true,
42+
3943
// Use the following option if you're on an SDK version lower than 7.47.0:
40-
// include: "./out",
44+
// release: {
45+
// uploadLegacySourcemaps: {
46+
// include: ".",
47+
// ignore: ["node_modules"],
48+
// },
49+
// },
4150

4251
// Optionally uncomment the line below to override automatic release name detection
4352
// release: process.env.RELEASE,
4453
}),
4554
],
4655
output: {
4756
sourcemap: true, // Source map generation must be turned on
48-
dir: "./out",
4957
},
5058
};
5159
```

src/platform-includes/sourcemaps/upload/vite/javascript.mdx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ yarn add @sentry/vite-plugin --dev
1212

1313
## Configuration
1414

15-
Learn more about configuring the plugin in our [Sentry Vite Plugin documentation](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin).
15+
Learn more about configuring the plugin in our [Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).
1616

1717
Example:
1818

@@ -40,11 +40,21 @@ export default defineConfig(({ command, mode }) => {
4040

4141
sourcemaps: {
4242
// Specify the directory containing build artifacts
43-
assets: "./dist/**",
43+
assets: "./**",
44+
// Don't upload the source maps of dependencies
45+
ignore: ["./node_modules/**"],
4446
},
4547

48+
// Helps troubleshooting - set to false to make plugin less noisy
49+
debug: true,
50+
4651
// Use the following option if you're on an SDK version lower than 7.47.0:
47-
// include: "./dist",
52+
// release: {
53+
// uploadLegacySourcemaps: {
54+
// include: ".",
55+
// ignore: ["node_modules"],
56+
// },
57+
// },
4858

4959
// Optionally uncomment the line below to override automatic release name detection
5060
// release: env.RELEASE,

src/platform-includes/sourcemaps/upload/webpack/javascript.mdx

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,65 @@
1-
Sentry uses [releases](/product/releases/) to match the correct source maps to your events.
21
You can use the Sentry Webpack plugin to automatically create releases and upload source maps to Sentry when bundling your app.
32

3+
<Note>
4+
5+
This guide for the Sentry Webpack plugin is for version `2.x` of the plugin.
6+
If you are using version `1.x` of `@sentry/webpack-plugin` please see the migration guide on how to update:
7+
https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/MIGRATION.md
8+
9+
</Note>
10+
411
## Installation
512

6-
```shell {tabTitle:npm}
7-
npm install --save-dev @sentry/webpack-plugin
13+
```bash {tabTitle:npm}
14+
npm install @sentry/webpack-plugin --save-dev
815
```
916

10-
```shell {tabTitle:Yarn}
11-
yarn add --dev @sentry/webpack-plugin
17+
```bash {tabTitle:Yarn}
18+
yarn add @sentry/webpack-plugin --dev
1219
```
1320

1421
## Configuration
1522

16-
Learn more about configuring the plugin in our [Sentry Webpack Plugin documentation](https://github.com/getsentry/sentry-webpack-plugin).
23+
Learn more about configuring the plugin in our [Sentry Webpack Plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin).
1724

1825
Example:
1926

2027
<PlatformSection notSupported={["javascript.gatsby"]}>
2128

2229
```javascript {filename:webpack.config.js}
23-
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
30+
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
2431

2532
module.exports = {
2633
// ... other config above ...
2734

2835
devtool: "source-map", // Source map generation must be turned on
2936
plugins: [
30-
new SentryWebpackPlugin({
37+
sentryWebpackPlugin({
3138
org: "___ORG_SLUG___",
3239
project: "___PROJECT_SLUG___",
3340

34-
// Specify the directory containing build artifacts
35-
include: "./dist",
36-
3741
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
38-
// and needs the `project:releases` and `org:read` scopes
42+
// and need `project:releases` and `org:read` scopes
3943
authToken: process.env.SENTRY_AUTH_TOKEN,
4044

45+
sourcemaps: {
46+
// Specify the directory containing build artifacts
47+
assets: "./**",
48+
// Don't upload the source maps of dependencies
49+
ignore: ["./node_modules/**"],
50+
},
51+
52+
// Helps troubleshooting - set to false to make plugin less noisy
53+
debug: true,
54+
55+
// Use the following option if you're on an SDK version lower than 7.47.0:
56+
// release: {
57+
// uploadLegacySourcemaps: {
58+
// include: ".",
59+
// ignore: ["node_modules"],
60+
// },
61+
// },
62+
4163
// Optionally uncomment the line below to override automatic release name detection
4264
// release: process.env.RELEASE,
4365
}),
@@ -50,24 +72,32 @@ module.exports = {
5072
<PlatformSection supported={["javascript.gatsby"]}>
5173

5274
```javascript {filename:gatsby-node.js}
53-
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
75+
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");
5476

5577
exports.onCreateWebpackConfig = ({ actions }) => {
5678
actions.setWebpackConfig({
5779
plugins: [
58-
new SentryWebpackPlugin({
80+
sentryWebpackPlugin({
5981
org: "___ORG_SLUG___",
6082
project: "___PROJECT_SLUG___",
6183

62-
ignore: ["app-*", "polyfill-*", "framework-*", "webpack-runtime-*"],
63-
64-
// Specify the directory containing build artifacts
65-
include: "public",
66-
6784
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
68-
// and needs the `project:releases` and `org:read` scopes
85+
// and need `project:releases` and `org:read` scopes
6986
authToken: process.env.SENTRY_AUTH_TOKEN,
7087

88+
sourcemaps: {
89+
// Specify the directory containing build artifacts
90+
assets: "./**",
91+
// Don't upload the source maps of dependencies
92+
ignore: ["./node_modules/**"],
93+
},
94+
95+
// Helps troubleshooting - set to false to make plugin less noisy
96+
debug: true,
97+
98+
// Use the following option if you're on an SDK version lower than 7.47.0:
99+
// include: "./dist",
100+
71101
// Optionally uncomment the line below to override automatic release name detection
72102
// release: process.env.RELEASE,
73103
}),
@@ -83,16 +113,3 @@ exports.onCreateWebpackConfig = ({ actions }) => {
83113
If you use [SourceMapDevToolPlugin](https://webpack.js.org/plugins/source-map-dev-tool-plugin) for more fine-grained control of source map generation, turn off `noSources` so Sentry can display proper source code context in event stack traces.
84114

85115
</Note>
86-
87-
The Sentry Webpack plugin will automatically inject a release value into the SDK so you must either omit the `release` option from `Sentry.init` or make sure `Sentry.init`'s `release` option matches the plugin's `release` option exactly:
88-
89-
```javascript
90-
Sentry.init({
91-
dsn: "___PUBLIC_DSN___",
92-
93-
// When using the plugin, either remove the `release`` property here entirely or
94-
// make sure that the plugin's release option and the Sentry.init()'s release
95-
// option match exactly.
96-
// release: "my-example-release-1"
97-
});
98-
```

src/platforms/javascript/guides/sveltekit/manual-setup.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ The `sentrySvelteKit()` function adds Vite plugins to your Vite config to:
185185

186186
## Configure Source Maps Upload
187187

188-
By default, `sentrySvelteKit()` will add an instance of the [Sentry Vite Plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin#sentry-vite-plugin), to upload source maps for both server and client builds. This means that when you run a production build (`npm run build`), source maps will be generated and uploaded to Sentry, so that you get readable stack traces in your Sentry issues.
188+
By default, `sentrySvelteKit()` will add an instance of the [Sentry Vite Plugin](https://www.npmjs.com/package/@sentry/vite-plugin), to upload source maps for both server and client builds. This means that when you run a production build (`npm run build`), source maps will be generated and uploaded to Sentry, so that you get readable stack traces in your Sentry issues.
189189

190190
However, you still need to specify your Sentry auth token as well as your org and project slugs. There are two ways to set them.
191191

@@ -196,7 +196,7 @@ You can set them as environment variables, for example in a `.env` file:
196196
- `SENTRY_AUTH_TOKEN` your Sentry auth token
197197
- `SENTRY_URL` your Sentry instance URL. This is only required if you use your own Sentry instance (as opposed to `https://sentry.io`).
198198

199-
Or, you can set them by passing a `sourceMapsUploadOptions` object to `sentrySvelteKit`, as seen in the example below. All available options are documented at [the Sentry Vite plugin repo](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin#configuration).
199+
Or, you can set them by passing a `sourceMapsUploadOptions` object to `sentrySvelteKit`, as seen in the example below. All available options are documented at [the Sentry Vite plugin repo](https://www.npmjs.com/package/@sentry/vite-plugin#options).
200200

201201
```javascript {filename:vite.config.js}
202202
import { sveltekit } from '@sveltejs/kit/vite';

0 commit comments

Comments
 (0)