Skip to content

[Bug report] config.js -> head will erase my link tag added from clientAppEnhance immediately after page loaded #426

@trickyEdecay

Description

@trickyEdecay

Bug report

Description

i'm making a plugin to load markdown-it-katex. it needs to add an <link> css to the html.

so i wrote something like below into the clientAppEnhance.js file and correctly referenced.

export default defineClientAppEnhance(() => {
    console.log('katex loaded')
    const styleTag = document.createElement('link')
    styleTag.href = 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css'
    styleTag.rel = 'stylesheet'
    document.head.appendChild(styleTag)
})

and i found that if i set something to .vuepress/config.js > head , the <link> tag i wrote above loaded but erase immediately.

i can see 'katex loaded' from console and the css request was sent from the network panel

and if i remove the content of .vuepress/config.js > head , everything goes well.

is this a bug or should i add tag from another place?

i think it is affected by this
https://github.com/vuepress/vuepress-next/blob/a0bf704ec6d1f8180d9bce6cd0af70a48cb6f09d/packages/%40vuepress/client/src/composables/updateHead.ts#L68

Steps to reproduce

  1. make an local plugin with clientAppEnhance.js file
  2. add <link> tag to <head> from defineClientAppEnhance
  3. add some <link> to .vuepress/config.js > head
  • Reproduction link / repo:

Expected behavior

the tag added from defineClientAppEnhance shouldn't be erased.

Screenshots

Environment info

  • Browser:
  • Output of vuepress info:
System:
    OS: macOS 11.5.2
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 26.65 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    Yarn: Not Found
    npm: 7.20.5 - ~/.nvm/versions/node/v14.15.0/bin/npm
  Utilities:
    Git: 2.18.0 - /usr/local/bin/git
  Browsers:
    Chrome: 92.0.4515.159
    Edge: Not Found
    Firefox: 91.0.2
    Safari: 14.1.2
  npmPackages:
    @vuepress/bundler-vite: Not Found
    @vuepress/bundler-webpack:  2.0.0-beta.25 
    @vuepress/cli:  2.0.0-beta.25 
    @vuepress/client:  2.0.0-beta.25 
    @vuepress/core:  2.0.0-beta.25 
    @vuepress/markdown:  2.0.0-beta.25 
    @vuepress/plugin-active-header-links: ^2.0.0-beta.25 => 2.0.0-beta.25 
    @vuepress/plugin-back-to-top:  2.0.0-beta.25 
    @vuepress/plugin-container:  2.0.0-beta.25 
    @vuepress/plugin-debug: Not Found
    @vuepress/plugin-docsearch: Not Found
    @vuepress/plugin-git:  2.0.0-beta.25 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.25 
    @vuepress/plugin-nprogress:  2.0.0-beta.25 
    @vuepress/plugin-palette:  2.0.0-beta.25 
    @vuepress/plugin-prismjs:  2.0.0-beta.25 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: Not Found
    @vuepress/plugin-search: Not Found
    @vuepress/plugin-shiki: ^2.0.0-beta.25 => 2.0.0-beta.25 
    @vuepress/plugin-theme-data:  2.0.0-beta.25 
    @vuepress/plugin-toc: ^2.0.0-beta.25 => 2.0.0-beta.25 
    @vuepress/shared:  2.0.0-beta.25 
    @vuepress/theme-default:  2.0.0-beta.25 
    @vuepress/utils:  2.0.0-beta.25 
    vue: ^3.2.6 => 3.2.6 
    vue-loader:  16.5.0 
    vue-router: ^4.0.11 => 4.0.11 
    vuepress: ^2.0.0-beta.25 => 2.0.0-beta.25 
    vuepress-vite: Not Found

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions