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

Expose vitepress user config to vite plugins #1706

Closed
3 tasks done
emersonbottero opened this issue Dec 16, 2022 · 3 comments · Fixed by #1822
Closed
3 tasks done

Expose vitepress user config to vite plugins #1706

emersonbottero opened this issue Dec 16, 2022 · 3 comments · Fixed by #1822
Labels
build Related to the build system enhancement New feature or request has-workaround Has workaround, low priority

Comments

@emersonbottero
Copy link

Describe the bug

Resolved config does not have srcExclude in it.

It is needed in my search plugin since I'm adding in the search index documents that should be excluded

Reproduction

log the resolved config in the plugin mentioned above.

Expected behavior

I should be able to get this settings in the plugin pipeline.

System Info

> playground@1.0.0 serve
  System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 9.15 GB / 15.92 GB
  Binaries:
    Node: 16.18.0 - C:\Program Files\nodejs\node.EXE    Yarn: 1.22.5 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.3 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Chrome: 108.0.5359.125
    Edge: Spartan (44.22621.1037.0), Chromium (108.0.1462.46)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vitepress: 1.0.0-alpha.30 => 1.0.0-alpha.30

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@emersonbottero emersonbottero added the bug: pending triage Maybe a bug, waiting for confirmation label Dec 16, 2022
@brc-dd
Copy link
Member

brc-dd commented Dec 20, 2022

That resolved config is actually Vite's one:

import { defineConfig } from 'vitepress';

export default defineConfig({
  vite: {
    // @ts-ignore
    foo: 'bar',

    plugins: [
      {
        name: 'test',
        configResolved(config) {
          // @ts-ignore
          console.log(config.foo); // prints bar
        },
      },
    ],
  },
});

@brc-dd brc-dd removed the bug: pending triage Maybe a bug, waiting for confirmation label Dec 20, 2022
@emersonbottero
Copy link
Author

how can I access srcExclude in an vite plugin for vitepress?

@brc-dd
Copy link
Member

brc-dd commented Dec 21, 2022

You'll probably need to ask users to put that option in the vite field (or vite.config), or maybe directly accept it as an option to your plugin?

PS: yeah it would need users to specify it twice.

@brc-dd brc-dd changed the title srxExclude is not exposed Expose vitepress user config to vite plugins Jan 2, 2023
@brc-dd brc-dd added enhancement New feature or request build Related to the build system has-workaround Has workaround, low priority labels Jan 2, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Related to the build system enhancement New feature or request has-workaround Has workaround, low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants