handlebars-template-loader
handlebars-template-loader copied to clipboard
Dynamic require macro path
Is it possible to have a dynamic paths in a require macro? I'm thinking in terms of loading a language variant:
@require('./header-' + language + '.hbs')
hello @sidonaldson , afaik you can't do this on webpack 1. I think is because the way webpack handles paths (they should always point to the actual resource).
@emaphp thanks for the quick reply. Maybe I could try aliasing the path and switching that per language instead. In theory that should work
I can confirm that alias
works:
// where language is set to 'en' for example
resolve: {
alias: {
test: path.resolve(__dirname, 'templates', language),
}
}
and then in a template
@require('~test/tracking-snippet.hbs')