getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
135 stars 35 forks source link

[Vite] No auth token provided in dev/watch mode warning #344

Open cleptric opened 1 year ago

cleptric commented 1 year ago

On https://docs.sentry.io/platforms/javascript/guides/vue/sourcemaps/uploading/vite/, we mention

The Sentry Vite plugin doesn’t upload source maps in watch-mode/development-mode. We recommend running a production build to test your configuration.

However, running vite, I get the following output.

❯ npm run dev

> dev
> vite

[sentry-vite-plugin] Warning: No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
[sentry-vite-plugin] Warning: No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/
owenjs commented 1 year ago

It seems:

Vite doesn't load .env files by default

So I needed to follow Vite's guide on how to use Environment variables within their config file

Not sure if this has changed recently but this plugin's example is wrong.

lforst commented 1 year ago

@owenjs I don't think any bundler loads .env files by default. I also don't think our example is wrong. If you wanna use vite's way of accessing environment configuration you have to do that, otherwise (as it says in those docs) "Environmental Variables can be obtained from process.env as usual".

@cleptric thanks for raising this, will fix.

franklinjavier commented 7 months ago

Using loadEnv did the trick https://main.vitejs.dev/config/#using-environment-variables-in-config Thank you