I have a vscode extension that is bundled using webpack. Referencing an npm package with import
or require
causes it and its dependencies to be bundled as expected.
Some of these bundled assets are not for use directly in my code, they are assets that I serve to a browser via an embedded webserver.
For CSS files getting the code is easy.
resources.set("katex.min.css", {
content: require("../node_modules/katex/dist/katex.css").default.toString(),
mimeType: "text/css; charset=utf-8;"
});
What I can’t figure out is how to get the source for a bundled module. I can’t specify raw-loader
for js files, that would mess up the normal use of require/import.
I’m also not clear on how this would work for package dependencies.
Does anyone else serve executable resources out of a bundle like this and if so how do you go about it?