web
web copied to clipboard
How to import HTML file using esbuild's text loader?
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:
There is no way to specify the text loader, so how can we achieve that?