ikenfin / vite-plugin-sentry

Vite plugin acting as an interface to SentryCLI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type checking too harsh

rassie opened this issue · comments

Luckily, it doesn't really matter in the end (everything still works), but the type ViteSentryPluginOptions does not take .sentryclirc and environment variables into account. I prefer keeping org and project in the .sentryclirrc to keep the compatibility to the real Sentry CLI and I also keep my authToken in an environment variable, since I wouldn't want to put it under source control, but rather use it in CI. Typescript compiler says it's missing these properties:

Type '{ release: string; configFile: string; deploy: { env: string; }; setCommits: { auto: false; }; sourceMaps: { include: string[]; ignore: string[]; urlPrefix: string; }; }' is missing the following properties from type 'ViteSentryPluginOptions': authToken, org, project

Not sure what can be done about that, but it would be nice if the compiler wouldn't complain.

Hi!

Good point about .sentryclirc, seems we need config option like rcfile that will make all these required fields optional. I will look what can be done to resolve such situations.

TIP:
You don't have to put token into source control, instead you can use environment variables as well 👍 Personally i use setup showed below in vite.config.ts - sensitive data comes as env variables from CI at the build time

const config: ViteSentryPluginOptions = {
  url: process.env.SENTRY_URL,
  authToken: process.env.SENTRY_AUTH_TOKEN,
  org: process.env.SENTRY_ORG,
  project: process.env.SENTRY_PROJECT,
  release: process.env.SENTRY_RELEASE,
  deploy: {
    env: process.env.NODE_ENV || 'development'
  },
  setCommits: {
    auto: true
  },
  sourceMaps: {
    include: [ './dist/assets' ],
    ignore: [ 'node_modules' ],
    urlPrefix: '~/assets/'
  }
}

Hi @rassie
I've made most plugin settings optional, so you can skip any of them which presented in rcfile 👍