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

Expose html transformation API #2270

Open
Djaler opened this issue Feb 26, 2021 · 4 comments
Open

Expose html transformation API #2270

Djaler opened this issue Feb 26, 2021 · 4 comments
Labels
enhancement New feature or request feat: html

Comments

@Djaler
Copy link

Djaler commented Feb 26, 2021

Is your feature request related to a problem? Please describe.
I tried to make a plugin to support asciidoctor files. I can easily transform adoc-file to html, but then I need to do a bunch of things over this html string to make all images correctly included into bundle (find all img tags and theirs src, transform them to imports, update src, etc). In webpack this is covered by html-loader. I see that this is also happened in plugin vite:build-html

Describe the solution you'd like
Maybe you can export API used in this plugin?

Describe alternatives you've considered
Without this the only way I see is too copy a bunch of code from vite or html-loader internals

@Djaler
Copy link
Author

Djaler commented Feb 26, 2021

The better way is to support html as a result of transform hook (vite should transform html to js itself after that)

@yyx990803 yyx990803 added the enhancement New feature or request label Feb 26, 2021
@Niputi
Copy link
Contributor

Niputi commented Nov 22, 2021

Hello @Djaler is this feature https://vitejs.dev/guide/api-plugin.html#transformindexhtml what you are looking for?

@Djaler
Copy link
Author

Djaler commented Nov 23, 2021

No. This hook allows me to add additional transformations for the entry point index.html.
I have a plugin that allows to import asciidoctor files as html. This files can contain images, videos, etc. And I want this static resources to be automatically imported to build. In webpack I can just return html string from my loader and then html-loader will do the magic. So now I just use html-loader code with some hacks https://github.com/Djaler/vite-plugin-asciidoc/blob/master/src/html/html-loader-adapter.ts

@sapphi-red
Copy link
Member

related: #2321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: html
Projects
None yet
Development

No branches or pull requests

5 participants