Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin's config hook supports return promise #2798

Closed
liuweiGL opened this issue Mar 31, 2021 · 0 comments · Fixed by #2800
Closed

plugin's config hook supports return promise #2798

liuweiGL opened this issue Mar 31, 2021 · 0 comments · Fixed by #2800
Labels
enhancement New feature or request p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@liuweiGL
Copy link
Contributor

Clear and concise description of the problem

I'm writting vite-certificate plugin to provide certificates for vite https dev server.

The plugin need:

  1. download mkcert lib from remote.
  2. use mkcert to install certificates.
  3. read certificate files and pass to vite config.server

the plugin is almost like this:

import { Plugin } from 'vite'
import { PLUGIN_NAME } from '../lib/constant'
import { getLocalV4Ips } from '../lib/util'
import Mkcert, { MkcertOptions } from '../mkcert'

export type ViteCertificateOptions = MkcertOptions

const plugin = (options: ViteCertificateOptions): Plugin => {
  return {
    name: PLUGIN_NAME,
    config: async config => {
      if (config.server?.https) {
        const ips = getLocalV4Ips()
        const mkcert = Mkcert.create(options)
        await mkcert.init()
        const certificates = await mkcert.install([...ips, 'localhost'])
        const keys = certificates.map(item => item.key)
        const certs = certificates.map(item => item.cert)
        if (config.server.https === true) {
          config.server.https = {
            key: keys,
            cert: certs
          }
        } else {
          Object.assign(config.server.https, {
            key: keys,
            cert: certs
          })
        }
      }
    }
  }
}

So, i want plugin's config hook to support return promise.

Suggested solution

Alternative

Additional context

@patak-dev patak-dev added enhancement New feature or request p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) and removed enhancement: pending triage labels Mar 31, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants