web icon indicating copy to clipboard operation
web copied to clipboard

How to import HTML file using esbuild's text loader?

Open HcySunYang opened this issue 1 year ago • 0 comments

ESbuild has a built-in text loader https://esbuild.github.io/content-types/#text, which allows us to load a file as a raw text string. So we are going to be able to load the HTML files as strings by making use of the text loader:

import content from './xxx.html'

But it will throw an error that says ERROR: No loader is configured for ".html" files: xxx.html, I looked into the source code, it seems because the lack of the loader configs:

image

There is no way to specify the text loader, so how can we achieve that?

HcySunYang avatar Jul 17 '24 02:07 HcySunYang