I am trying to use handlebars in a client webpart using these posts:
https://n8d.at/blog/how-to-use-handlebars-in-sharepoint-framework-projects-spfx/ https://n8d.at/blog/first-handlebars-web-part-in-spfx/
in my gulp.js file, i have this code:
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration)=> {
generatedConfiguration.module.rules.push(
{ test: /\.hbs$/, loader: "handlebars-template-loader" } );
return generatedConfiguration;
}
});
build.initialize(gulp);
I created a new file under config folder, called copy-static.assets.json, with this code inside:
{"includeExtensions": ["hbs"]}
i have the template on the same level as .ts webpart file, and i reference the template like this:
var compiled = require('./test.hbs');
am getting this error when I run gulp serve:
Module not found: Error: Can't resolve './test.hbs' using description file: C:\solutions\mywebpart\package.json . Field 'browser' doesn't contain a valid alias configuration.
Any idea how to solve this?