In order to work with files with the .hmpl
extension, you can install a webpack and loader for it hmpl-loader. Since version 0.0.2
, the loader connection looks like this:
webpack.config.js
module.exports = { module: { rules: [ { test: /\.hmpl$/i, use: ["hmpl-loader"], } ] }
}
main.hmpl
<div><request src="/api/test"></request></div>
main.js
const templateFn = require("./main.hmpl"); const elementObj = templateFn();