vitepress icon indicating copy to clipboard operation
vitepress copied to clipboard

Favicon not found when base is set by command line

Open mikigo opened this issue 9 months ago • 6 comments

Describe the bug

// .vitepress/config.ts

head: [
        base: '/youqu/',
        ['link', {rel: 'icon', href: "/youqu/favicon.ico"}],
],

I need to build on two websites, one of which cannot find Favicon when using

pnpm run build --base /

How to dynamically specify base using the command line in Favicon?

Reproduction

How to dynamically specify base using the command line in Favicon?

Expected behavior

The Favicon configuration has added a base, which can still be dynamically specified through the command line

System Info

System:
    OS: Deepin 20.9
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 39.5 GB
  Binaries:
    Node: 18.16.1
    npm: 9.5.1
  Browsers:
    Edge: Spartan (44.22621.746.0), Chromium (106.0.1370.47)
  npmPackages:
    vitepress: 1.0.0-rc.36

Additional context

No response

Validations

mikigo avatar May 08 '24 02:05 mikigo

help~~😂😂

mikigo avatar May 10 '24 07:05 mikigo

You currently cannot. You can use some environment variable instead:

BASE='/' pnpm run build

In config:

base: process.env.BASE,
... href: `${process.env.BASE || '/'}favicon.ico` ...

brc-dd avatar May 10 '24 07:05 brc-dd

cool...I'll give it a try.thanks homie.😘😘

mikigo avatar May 10 '24 07:05 mikigo

ohno

image

why process.env.BASE is undefined

mikigo avatar May 10 '24 08:05 mikigo

Don't use --base. You need to do BASE='/youqu/' pnpm run dev

brc-dd avatar May 10 '24 08:05 brc-dd

ok, cool, bro~~

It worked. thanks 😘😘

mikigo avatar May 10 '24 09:05 mikigo