emersonbottero / vitepress-plugin-search

Provide local search to your documentation site.
MIT License
238 stars 30 forks source link

vitepress build error: search function is not working after build #40

Closed haiting closed 1 year ago

haiting commented 1 year ago

https://stackblitz.com/edit/vitejs-vite-amht1g?file=src%2Fcomponents.js,docs%2F.vitepress%2Fconfig.js

wuchaoxin commented 1 year ago

I have the same problem. When I updated the latest dependency, the error disappeared, but I still could not search in the build environment.

emersonbottero commented 1 year ago

I couldn't replicate this error! could you share an repo? (couldn't make the stackblitz to work...)

AnWeber commented 1 year ago

Hi I got the same error. My repo is https://github.com/httpyac/httpyac.github.io#51 but you need to revert commit https://github.com/httpyac/httpyac.github.io/commit/3796c70c97dbfccb681776c1505de41736dc6b97. Maybe it helps.

emersonbottero commented 1 year ago

Hi I got the same error. My repo is https://github.com/httpyac/httpyac.github.io#51 but you need to revert commit httpyac/httpyac.github.io@3796c70. Maybe it helps.

but you try to set it up in docs/.vitepress/config.js ..

it should be in docs/vite.config.ts

it seams the above cases are the same!

AnWeber commented 1 year ago

@emersonbottero thx. That did the trick. It is some kind of unexpected that configuration also works in config.ts, but only in dev build. Maybe highlight this issue in your readme or add some kind of build warning (if possible) to prevent this issue.

wuchaoxin commented 1 year ago

Hi I got the same error. My repo is https://github.com/httpyac/httpyac.github.io#51 but you need to revert commit httpyac/httpyac.github.io@3796c70. Maybe it helps.

but you try to set it up in docs/.vitepress/config.js ..

it should be in docs/vite.config.ts

it seams the above cases are the same!

wow, It works!

 docs/.vitepress/config.ts
 docs/vite.config.ts

But what is the difference between the two settings?

emersonbottero commented 1 year ago

The first one is vitepress configuration specific..

The second one is a vite configuration and uses roll-up lifecycle to change behavior.

emersonbottero commented 1 year ago

@emersonbottero thx. That did the trick. It is some kind of unexpected that configuration also works in config.ts, but only in dev build. Maybe highlight this issue in your readme or add some kind of build warning (if possible) to prevent this issue.

I think I can warn! 😁

haiting commented 1 year ago

It works! Thx!!!