VirtualWolf
04/25/2023, 12:12 PMimport * as template from './templates/template.mustache
for use with the Mustache library itself.
I've come across the workaround of loading the templates from R2 or KV, but I'd like to avoid that if at all possible. Really all I need is just to get them in as a string, I've seen things like this https://stackoverflow.com/questions/46503615/import-html-from-typescript-with-webpack but they're all based on mucking around with Webpack configuration. Given I'm new to all this ideally I'd like to be able to have it working locally with Wrangler2 as well. My understanding is that Wrangler2 uses esbuild
under the covers, is there some customisation I can do with that to make this happen? 🙂 Or something other method that would allow this to work?
Any thoughts or insights are greatly appreciated. ❤️VirtualWolf
04/25/2023, 12:18 PMVirtualWolf
04/25/2023, 12:18 PMVirtualWolf
04/25/2023, 12:19 PMVirtualWolf
04/25/2023, 12:22 PMdeclare module '*.mustache' {
const content: string;
export default content;
}
And tell TypeScript about it at the top of the file I'm importing into:
/// <reference path="mustache.d.ts"/>
Skye
04/25/2023, 12:23 PMVirtualWolf
04/25/2023, 12:23 PMVirtualWolf
04/25/2023, 12:23 PMVirtualWolf
04/26/2023, 5:13 AMtsconfig.json
I'd be setting for that? I haven't been able to figure it out thus far. 😦Skye
04/26/2023, 6:40 AMVirtualWolf
04/26/2023, 8:55 AMVirtualWolf
04/26/2023, 8:58 AMVirtualWolf
04/26/2023, 9:00 AMVirtualWolf
04/26/2023, 9:00 AM.d.ts
file has to be named the same as the module I'm declaring (i.e. I changed it to mustache.d.ts
and everything works). 🎉Skye
04/26/2023, 9:13 AM