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

feat: provide build end hook #709

Merged
merged 2 commits into from Jul 9, 2022
Merged

Conversation

userquin
Copy link
Collaborator

@userquin userquin commented Jun 3, 2022

should also be included on next ;)

closes #706

@userquin userquin marked this pull request as draft June 3, 2022 15:31
@userquin
Copy link
Collaborator Author

userquin commented Jun 3, 2022

It seems Vitepress is not resolving the root Vite config, only expose the inlined Vite configuration and not resolving it via Vite resolveConfig.

I need to do this to make vite-plugin-pwa work (accessing the Vite plugin on buildEnd doesn't work):

import { defineConfig } from 'vitepress'
import { resolveConfig } from 'vite'
import type { VitePluginPWAAPI } from 'vite-plugin-pwa'
import { VitePWA } from 'vite-plugin-pwa'

const PWA = VitePWA({...})
...
export default defineConfig({
  lang: 'en-US',
  ...
  // add the plugin also to allow run on dev
  vite: {
    plugins: [PWA],
  },
  async buildEnd() {
      const viteConfig = await resolveConfig({
          plugins: [PWA],
        },
        'build',
        'production',
      )
      const pwaPlugin: VitePluginPWAAPI = viteConfig.plugins.find(i => i.name === 'vite-plugin-pwa')?.api
      const pwa = pwaPlugin && !pwaPlugin.disabled
      await optimizePages(pwa)
      if (pwa)
        await pwaPlugin.generateSW()
    },
})

@userquin userquin marked this pull request as ready for review June 3, 2022 16:10
userquin added a commit to vite-pwa/vite-plugin-pwa that referenced this pull request Jun 6, 2022
Until vuejs/vitepress#709 merged/released on `Vitepress` we'll need old version of `esno` to use it on docs build
@brc-dd brc-dd merged commit e0b730a into vuejs:main Jul 9, 2022
@userquin userquin deleted the feat/add-build-end-hook branch July 13, 2022 14:57
@jbaubree jbaubree mentioned this pull request Aug 11, 2022
4 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provide build end hook
2 participants