slidev icon indicating copy to clipboard operation
slidev copied to clipboard

resolve `vite.config.ts` in parent directory

Open pinage404 opened this issue 1 year ago • 4 comments

Hi,

Describe the bug

Markdown-it plugin seems to not work when the slides.md file is in a subfolder

Minimal reproduction

Steps to reproduce the behavior:

I did a minimal reproductible test repository https://gitlab.com/pinage404/slidev_bad_subfolder_behavior/-/commits/main/?ref_type=HEADS

  1. having the slides.md file in a subfolder

    slidev build ./subfolder/slides.md
    
  2. with this content in the slides.md

    Normal ^sup^ normal
    
  3. add markdown-it plugin

With [email protected], plugin works With [email protected], the build works but the plugin seems ignored With [email protected] (current latest), same behavior as 0.49.11

Alternative solution

Moving the slides.md in the root folder fix it

Additional context

I noticed the backward incompatibility on this slide (the corresponding code)

Environment

  • Slidev version: 0.49.11 and newer
  • Browser: not relevant, it fails event when building Firefox 128.0.2 (64-bit)
  • OS: NixOS 24.05.20240725.a1cc729 (Uakari) x86_64

~~If you are using Slidev globally (i.e. npx slidev or npm i -g slidev), please try to reproduce the issue in a local project (i.e. npm create slidev@latest).~~

It was really long and hard to isolate the problem, good luck with this one

pinage404 avatar Jul 27 '24 17:07 pinage404

Sorry, I can't see the content of your vite.config.ts. GitLab says 404 NotFound

kermanx avatar Jul 28 '24 02:07 kermanx

Weird, it works for me

Here is the content

import MarkdownItSup from 'markdown-it-sup'
import { defineConfig } from 'vite'

export default defineConfig({
    slidev: {
        markdown: {
            markdownItSetup(md) {
                md.use(MarkdownItSup)
            },
        },
    },
})

pinage404 avatar Jul 28 '24 12:07 pinage404

It seems that the vite.config.ts hasn't been run. Move the vite.config.ts to the subfolder (next to slides.md) can fix this. Let's keep this issue open so that we can improve the behavior of the detection of "user root".

kermanx avatar Jul 29 '24 05:07 kermanx

It used to work in 0.49.10 and below

I imagine that 0.49.11 introduces a behavior change

Thanks, i did a symlink in the subfolders this fix the issue

pinage404 avatar Jul 29 '24 22:07 pinage404

Hey folks, what's the current status of moving slides to a nested folders? I run a single slidev setup with multiple slides and noticed this issue. Layouts are not found too, so I moved back to leaving slides in the root folder, which I guess is not so bad, but I am wondering what's the expected behaviour.

eric-burel avatar Nov 12 '24 18:11 eric-burel

There are two not bad workaround:

  1. Extract shared vite.config.ts and setups/* to a new directory, and use the directory as an addon.
  2. Add ../ as an addon

kermanx avatar Feb 21 '25 10:02 kermanx