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

How can you require a template generated on the server side (not available on compile time)? #2326

Closed
plrenaudin opened this issue Apr 12, 2016 · 1 comment
Labels

Comments

@plrenaudin
Copy link

Hello,
First of all, sorry for raising an issue for this question.

I want to achieve the RequireJS equivalent of

define(['text!/templates/myTemplate','underscore'], function (templateFile, _) { 
     // templateFile contains the content of (/template/myTemplate)
...});

In this case, /templates/myTemplate is a url serving the compiled template file.
So I need Webpack to generate a bundle with the underscore dependency but also, on runtime, to load the result of /templates/myTemplate (and pass it through an html loader I guess).

How can this be achieved using Webpack?

This is the behaviour on RequireJS link

Thank you

@sokra
Copy link
Member

sokra commented Apr 13, 2016

No this can't be required with webpack. webpack only cares for compile-time dependencies. You need to use XHR or a lib like async.js to load these files on runtime.

@sokra sokra closed this as completed Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants