vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.59k stars 4.76k forks source link

vuepress build with `--debug` flag breaks doc search #1944

Open favoyang opened 5 years ago

favoyang commented 5 years ago

Bug report

vuepress build with "--debug" flag breaks doc search, and perhaps other features.

Steps to reproduce

1) create a project with docs folder. 2) yarn add -D vuepress serve 3) add a few random markdown files into the docs folder. 4) vuepress build docs && serve docs/.vuepress/dist works. 5) vuepress build docs --debug && serve docs/.vuepress/dist. then try doc search function, type anything without response.

What is expected?

It shall work with or without --debug flag

What is actually happening?

Not only doc search failed, the vue devtools can not detect vue on the page.

Other relevant information

Environment Info:

System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-2635QM CPU @ 2.00GHz
Binaries:
Node: 10.16.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.19.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.10.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.18362.387.0
npmPackages:
@vuepress/core: Not Found
@vuepress/theme-default: Not Found
vuepress: ^1.2.0 => 1.2.0
npmGlobalPackages:
vuepress: Not Found

haoranpb commented 5 years ago

Build with --debug will also keep menus in the sidebar from expanding, see #1913

tskrynnyk commented 5 years ago

Build without --debug flag gives the same effect on the phone - sidebar not expand and search form not search.

ptandler commented 4 years ago

I also stepped over the issue (with VuePress cli.js/1.2.0 win32-x64 node-v12.13.0) that using --debug with build creates a site that is not fully functional.

@tskrynnyk For me it does work without "--debug".

I did notice that no mounted hooks are called, see my stackoverflow question. The --debug option works fine with dev. This causes that no event listeners are attached, breaking a lot of stuff.

If you read the VuePress CLI documentation carefully, you might notice that this option is intended for development server only.

However, I would expect that

I created a tiny VuePress project for me to reproduce the error while I was debugging.

haoranpb commented 4 years ago

@ptandler Nice Catch! Never notice that 👍

ptandler commented 4 years ago

Oh, well, it took me quite a while to figure out what was wrong with my build ;-)

haoranpb commented 4 years ago

I made some tests. Change this line https://github.com/vuejs/vuepress/blob/4c6fbcc5736c72f32e4a8208d5cfa46d86b2bf22/packages/%40vuepress/core/lib/node/webpack/createBaseConfig.js#L46

into

if (env.isDebug && !isProd) {

seems to solve the problem.

thekiwi commented 4 years ago

This also caught me out when using the mermaidjs plugin - it would definitely be good to see either a fix or some sort of warnings like ptandler suggested!