slidev
slidev copied to clipboard
[Feature Request] Allow build with multiple markdown entries
Is your feature request related to a problem? Please describe. My team uses slidev to present slides every week, and our project directory looks like this:
root
components
slides
20210710.md
20210717.md
20210724.md
package.json
I want to build all this slides into a SPA but it seems that slidev only supports building with single entry.
Describe the solution you'd like
slidev build [file1] [file2]
slidev build [directory]
Describe alternatives you've considered N/A
Why not just running the script multiple times?
Why not just running the script multiple times?
Because the assets that slidev generates could have been shared, but it didn't.
dist
assets
vendor.xxxxxx.js
index.html
What I want is
dist
assets
vendor.xxxxxx.js
1.xxxxxx.js (for 20210710.md)
2.xxxxxx.js (for 20210717.md)
3.xxxxxx.js (for 20210724.md)
20210710.html
20210717.html
20210724.html
And each of the generated HTML file shares something in common (vendor).
I guess this could be done by providing multiple input entries to Vite's build. PR Welcome.
cross referencing https://github.com/slidevjs/slidev/issues/479 https://github.com/slidevjs/slidev/issues/505
I made an implementation that is working You can access at: https://github.com/gabriel-del/slidev All feedbacks are welcome
I made an implementation that is working You can access at: https://github.com/gabriel-del/slidev All feedbacks are welcome
This no longer works with @slidev/cli v0.32.3
as it fails to resolve package.json under the presentations
folder.
It works to my friends, it takes some time to buid, maybe 3min, and maybe you need to use npm instead of yarn. Did you get any error mesage?
Yes I'm using npm.
> ./slidev.sh build
Error: Failed to resolve package "/*******/my-slides/presentations/package.json"
at resolveImportPath (/*******/my-slides/node_modules/@slidev/cli/dist/chunk-JWGORJY6.js:121:11)
at getPackageJson (/*******/my-slides/node_modules/@slidev/cli/dist/chunk-N7XL66RP.js:9515:72)
at getAddons (/*******/my-slides/node_modules/@slidev/cli/dist/chunk-N7XL66RP.js:9518:33)
at resolveOptions (/*******/my-slides/node_modules/@slidev/cli/dist/chunk-N7XL66RP.js:9600:24)
at async Object.handler (*****/my-slides/node_modules/@slidev/cli/dist/cli.js:172:19)
@gabriel-del I get:
6:19:30 PM [vite] Internal server error: EMFILE: too many open files, open '/home/animesh/TrashThings/testing/slidev/node_modules/dagre-d3/node_modules/d3-scale-chromatic/src/categorical/Paired.js'
What this does is just to iterate through the presentations and build each of them independently. But I fact it will not really solve the problem of build files to be different. Some files are the same between the build of 2 different slides, and some are different.
For example ,the generated dist/assets/nav-*.js
contains the content of the slides, so it will automatically be different between two different presentation.
Also some other files will be different simply because they import that dist/assets/nav-*.js
file for exemple, and because the filename of that imported file is different, then that other file is also different.
We can't really also provide multiple input entries to Vite's build because the entrypoint remains the same for all the slides (that file: https://github.com/slidevjs/slidev/blob/main/packages/client/main.ts).
Maybe one option would be to customize how vite manages and creates the files in the bundle to create files that will contains the maximum of shared code and to isolate specific code that only applies to one presentation (I think it mostly concern virtual imports /@slidev/routes
, /@slidev/configs
...etc.).
But I have no idea how this coule be done.
I made a PR (https://github.com/slidevjs/slidev/pull/844) to allow the CLI to take multiple entry files when building or exporting. That won't solve the shared assets problem, but this way it doesn't require external script to work.