Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to use assets or markdown files with space in name #573

Closed
3 tasks done
jinlianglou opened this issue Mar 8, 2022 · 4 comments
Closed
3 tasks done

unable to use assets or markdown files with space in name #573

jinlianglou opened this issue Mar 8, 2022 · 4 comments
Labels
bug Something isn't working build Related to the build system has-workaround Has workaround, low priority stale upstream Related to the dependencies

Comments

@jinlianglou
Copy link

Describe the bug

当xxx.md中引用了图片,而图片的名字中含有空格则build失败
如图:
WX20220308-210322@2x

图片名字如下:
Screenshot 2021-07-05 at 12.53.29.png

在xxx.md中去掉相关以下内容 build 成功。
![Screenshot 2021-07-05 at 12.53.29.png](gettingstande.assets/Screenshot%202021-07-05%20at%2012.53.29.png)

Reproduction

yarn build:docs

Expected behavior

希望有空可以优化下。

System Info

System:
    OS: macOS 12.0.1
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 16.57 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.13.1 - /usr/local/bin/node
    Yarn: 1.5.1 - /usr/local/bin/yarn
    npm: 8.1.2 - /usr/local/bin/npm
  Browsers:
    Chrome: 93.0.4577.82
    Edge: 99.0.1150.36

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@jinlianglou jinlianglou added the bug: pending triage Maybe a bug, waiting for confirmation label Mar 8, 2022
@kiaking kiaking added bug Something isn't working build Related to the build system and removed bug: pending triage Maybe a bug, waiting for confirmation labels May 24, 2022
@kiaking kiaking added this to the v1.0.0 milestone May 27, 2022
@brc-dd
Copy link
Member

brc-dd commented May 29, 2022

Most likely, this won't be fixed anytime soon. Similar issues are open in VuePress for over 2 years.

@brc-dd brc-dd changed the title build error unable to use assets with space in name May 29, 2022
@kiaking
Copy link
Member

kiaking commented May 30, 2022

I guess this is the current limitation in Vite? Found this issue.
vitejs/vite-plugin-vue#218.

@kiaking kiaking removed this from the v1.0.0 milestone Jan 27, 2023
@yyx990803 yyx990803 added upstream Related to the dependencies has-workaround Has workaround, low priority labels Mar 13, 2023
@brc-dd brc-dd changed the title unable to use assets with space in name unable to use assets or markdown files with space in name Apr 30, 2023
@Jeff-Tian
Copy link
Contributor

Most likely, this won't be fixed anytime soon. Similar issues are open in VuePress for over 2 years.

vuejs/vuepress#2152 ?

@Jeff-Tian
Copy link
Contributor

Jeff-Tian commented Jul 11, 2023

vuejs/core#8752 might fix it.

Before the fix, there is a workaround, which works great as I've been using it for months:

  1. Create a postinstall.js file and paste the following code:
const fs = require('fs');

const filePath = 'node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js';

fs.readFile(filePath, 'utf8', (err, data) => {
    if (err) {
        console.error(err);
        return;
    }

    const modifiedData = data.replace(
        /context.imports\.push\(\{\s*exp,\s*path:\s*path2\s*}\);/g,
        "context.imports.push({ exp, path: path2 && path2[0] === '/' ? decodeURIComponent(path2) : path2 });"
    );

    fs.writeFile(filePath, modifiedData, 'utf8', (err) => {
        if (err) {
            console.error(err);
            return;
        }

        console.log('File modified successfully!');
    });
});

  1. Add a line to package.json's scripts:
+     "postinstall": "node postinstall.js"

@github-actions github-actions bot added the stale label Oct 8, 2023
yyx990803 pushed a commit to vuejs/core that referenced this issue Oct 21, 2023
By decoding them before generating them as JavaScript import paths

fix vuejs/vitepress#2596
fix vuejs/vitepress#573
lumozx pushed a commit to lumozx/core that referenced this issue Oct 21, 2023
By decoding them before generating them as JavaScript import paths

fix vuejs/vitepress#2596
fix vuejs/vitepress#573
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working build Related to the build system has-workaround Has workaround, low priority stale upstream Related to the dependencies
Projects
None yet
Development

No branches or pull requests

5 participants