Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic require macro path #21

Open
sidonaldson opened this issue Mar 1, 2017 · 3 comments
Open

Dynamic require macro path #21

sidonaldson opened this issue Mar 1, 2017 · 3 comments

Comments

@sidonaldson
Copy link

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')
@emaphp
Copy link
Owner

emaphp commented Mar 2, 2017

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).

@sidonaldson
Copy link
Author

@emaphp thanks for the quick reply. Maybe I could try aliasing the path and switching that per language instead. In theory that should work

@sidonaldson
Copy link
Author

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants