vuepress-community icon indicating copy to clipboard operation
vuepress-community copied to clipboard

[Bug Report] vuepress-plugin-clean-urls causes build errors when indexSuffix is empty string

Open killroyboy opened this issue 5 years ago • 7 comments

Environment

  • Package version: [email protected]
  • VuePress version: 1.2.0
  • OS: MacOS 10.15.3
  • Browser: Chrome 79.0.3945.130

Describe the bug

I have added an index.html and config.yml file (for NetlifyCMS integration). This works perfectly until I enable the clean-urls plugin. It appears this plugin is attempting to parse them in some way.

Steps To Reproduce

  1. Follow the instructions from here to add the admin/index.html and admin/config.yml
  2. Perform a vuepress build: vuepress build

Results in the following errors when run with --debug (I renamed by "doc" folder to "src"):

$ vuepress build src --debug
debug global_options { theme: '@vuepress/default' }
debug build_options { '--': [], cache: true, debug: true }
wait Extracting site metadata...
debug sourceDir /Users/danwilson/git/graphite/www-site/src
debug Temp directory: /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp
tip Apply local theme at /Users/danwilson/git/graphite/www-site/src/.vuepress/theme...
tip Apply theme local ...
debug theme local /Users/danwilson/git/graphite/www-site/src/.vuepress/theme
debug parentTheme undefined undefined
debug SSR Template File: /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/index.ssr.html
debug DEV Template File: /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/index.dev.html
debug globalLayout: /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
debug Plugins defined at @vuepress/internal-site-config { '@vuepress/google-analytics': { ga: 'UA-135254752-1' },
  'vuepress-plugin-serve': { port: 8082 },
  'vuepress-plugin-clean-urls': { normalSuffix: '', indexSuffix: '' },
  '@vuepress/search': { searchMaxSuggestions: 10 } }
debug Apply plugin @vuepress/internal-site-data ...
debug Apply plugin @vuepress/internal-routes ...
debug Apply plugin @vuepress/internal-root-mixins ...
debug Apply plugin @vuepress/internal-enhance-app ...
debug Apply plugin @vuepress/internal-palette ...
debug Apply plugin @vuepress/internal-style ...
debug Apply plugin @vuepress/internal-layout-components ...
debug Apply plugin @vuepress/internal-page-components ...
debug Apply plugin @vuepress/internal-transform-modules ...
debug Apply plugin @vuepress/internal-data-block ...
debug Apply plugin @vuepress/internal-frontmatter-block ...
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
debug [@vuepress/plugin-last-updated] disabled.
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
debug Apply plugin @vuepress/internal-theme-entry-file ...
debug Apply plugin @vuepress/internal-theme-api ...
debug Apply plugin @vuepress/internal-site-config ...
tip Apply plugin @vuepress/google-analytics (i.e. "@vuepress/plugin-google-analytics") ...
tip Apply plugin serve (i.e. "vuepress-plugin-serve") ...
tip Apply plugin clean-urls (i.e. "vuepress-plugin-clean-urls") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
debug applySyncOption: chainMarkdown
debug applySyncOption: extendMarkdown
debug applyAsyncOption: additionalPages
debug applyAsyncOption: ready
debug applyAsyncOption: clientDynamicModules
debug applyAsyncOption: enhanceAppFiles
debug applyAsyncOption: globalUIComponents
debug Cache directory: /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/node_modules/.cache/vuepress
debug Cache identifier : {"vuepress":"1.2.0","cache-loader":"3.0.1","vue-loader":"3.0.1","isProd":true,"config":""}
debug Dist directory: /Users/danwilson/git/graphite/www-site/dist
debug applySyncOption: define
debug applySyncOption: alias
debug applySyncOption: chainWebpack
debug applySyncOption: define
debug applySyncOption: alias
debug applySyncOption: chainWebpack
(undefined) ./src/.vuepress/public/admin/config.yml 8:0
Module parse failed: Unexpected character '#' (8:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   app_id: ************
|
> #publish_mode: editorial_workflow
|
| media_folder: "/src/.vuepress/public/images"
 @ ./src/.vuepress/public sync ^\.\/.*$ ./admin/config.yml
 @ /Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--3-0!/Users/danwilson/.config/yarn/global/node_modules/babel-loader/lib??ref--3-1!/Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--0-0!/Users/danwilson/.config/yarn/global/node_modules/vue-loader/lib??vue-loader-options!./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/app-enhancers/global-components-1.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/internal/app-enhancers.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/app.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/clientEntry.js
 @ multi /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/clientEntry.js
(undefined) ./src/.vuepress/public/admin/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
 @ ./src/.vuepress/public sync ^\.\/.*$ ./admin/index.html
 @ /Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--3-0!/Users/danwilson/.config/yarn/global/node_modules/babel-loader/lib??ref--3-1!/Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--0-0!/Users/danwilson/.config/yarn/global/node_modules/vue-loader/lib??vue-loader-options!./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/app-enhancers/global-components-1.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/internal/app-enhancers.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/app.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/clientEntry.js
 @ multi /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/clientEntry.js
(undefined) ./src/.vuepress/public/admin/config.yml 8:0
Module parse failed: Unexpected character '#' (8:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|   app_id: ***********
|
> #publish_mode: editorial_workflow
|
| media_folder: "/src/.vuepress/public/images"
 @ ./src/.vuepress/public sync ^\.\/.*$ ./admin/config.yml
 @ /Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--3-0!/Users/danwilson/.config/yarn/global/node_modules/babel-loader/lib??ref--3-1!/Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--0-0!/Users/danwilson/.config/yarn/global/node_modules/vue-loader/lib??vue-loader-options!./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/app-enhancers/global-components-1.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/internal/app-enhancers.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/app.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/serverEntry.js
 @ multi /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/serverEntry.js
(undefined) ./src/.vuepress/public/admin/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
 @ ./src/.vuepress/public sync ^\.\/.*$ ./admin/index.html
 @ /Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--3-0!/Users/danwilson/.config/yarn/global/node_modules/babel-loader/lib??ref--3-1!/Users/danwilson/.config/yarn/global/node_modules/cache-loader/dist/cjs.js??ref--0-0!/Users/danwilson/.config/yarn/global/node_modules/vue-loader/lib??vue-loader-options!./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue?vue&type=script&lang=js&
 @ ./src/.vuepress/components/EndorsementSlide.vue
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/app-enhancers/global-components-1.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/.temp/internal/app-enhancers.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/app.js
 @ /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/serverEntry.js
 @ multi /Users/danwilson/.config/yarn/global/node_modules/@vuepress/core/lib/client/serverEntry.js
wait Rendering static HTML...
Rendering page: error Error rendering : false
undefined
undefined

Screenshots

Expected behavior

Build should be completed without errors.

Additional context

killroyboy avatar Jan 29 '20 20:01 killroyboy

I've created a repo that replicates the problem: https://github.com/killroyboy/vuepress-clean-urls-test

It currently shows the error when building. Commenting out the vuepress-plugin-clean-urls settings in config.js allows building without errors.

killroyboy avatar Jan 29 '20 20:01 killroyboy

Strange. This plugin should not have this kind of side effect. I'll try to confirm it.

meteorlxy avatar Jan 30 '20 18:01 meteorlxy

@killroyboy I cannot reproduce the bug totally.

In your repo:

  • I delete docs/.vuepress/public totally but there are still errors.
  • I rename docs/README.md to docs/a.md and things work well.

So seems like this is not caused by the config.yml and index.html files?

meteorlxy avatar Jan 30 '20 20:01 meteorlxy

@killroyboy I cannot reproduce the bug totally.

I'm not sure that makes me feel any better. So my diagnosis was obviously incorrect.

In my testing, if the file is named README.md or index.md, the build fails.

killroyboy avatar Jan 31 '20 19:01 killroyboy

@meteorlxy Figured it out. Well, not the reason, but a workaround.

If I remove indexSuffix from my plugin options then the build completes.

Perhaps it doesn't like indexSuffix set to empty quotes?

Hopefully, that gives you some additional ideas of the root cause.

killroyboy avatar Jan 31 '20 20:01 killroyboy

Uh, well, it maybe related to the known issue https://github.com/vuepress/vuepress-plugin-clean-urls/issues/1

There are still some issues of this plugin before migration to this repo

meteorlxy avatar Feb 01 '20 07:02 meteorlxy

Ahh... I was unaware of the other repo. I'm assuming we should leave this bug in place seeing as the other repo is archived?

killroyboy avatar Feb 01 '20 19:02 killroyboy