-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support 'html-webpack-plugin'? #35
Comments
Unfortunately this is difficult (possibly won't fix) due to how nunjucks 2.x loads dependencies (and a lack of UMD support). |
What is the exact problem, though? It seems that
Instead of:
If that's the case, then perhaps users can use the exports loader somehow? |
Nunjucks uses it's own mechanism for loading dependencies and that mechanism depends on the template object (and not just the What this means (and getting to the exact problem) is that when b depends on a, it's dependent on a being an instance of In regards to the non-web targets are not supported - the 1.x versions of this library did support UMD/node build targets, but a packaging change when nunjucks 2.x was released made this difficult - as a result, I dropped node support. That said, there have been a few changes to nunjucks recently that may make this possible again. |
I'm getting the same here. Using:
|
Still possible ? |
@at0g yes ? no ? Thank you |
@stephanedemotte that's a no for now |
Thanks ;) |
Anyone needing to use Nunjucks with
|
@Aendrew Thank you! Your post lead me to my current solution. In conjunction with this post, I was able to come up with a solution that allows me to use a .njk or .nunjucks file as an entry point: First, we install nunjucks-html-loader: Or with yarn: Imagine we have the following folder structure:
Inside index.njk:
As you can see I'm including layout.njk inside my index.njk Here's how we achieve it with Webpack: You're flexible to modify it. Second, we configure Webpack with the following:
Run webpack, and you shall be ready to go ;) |
Thank you @superjose ! This was helpful but I still got a little issue here. I cannot manage to pass data from webpack to the templates. Even I tried the following
And defining global variables in my EDIT: Nevermind, I just realized |
@3dos Wait. Are you referring to using layouts on nunjucks? |
@superjose I finally tried another loader, details on stackoverflow |
Can gulp tasks related to nunjucks be somehow helpful? It is sad that we have no robust loader in webpack ecosystem... |
Have a look at #60 |
Html-Webpack-Plugin is just a
index.html
compiler.It can use with template like below.
If I try with
nunjucks-loader
, I've got[nunjucks-loader] non-web targets are not supported
.What about support it? 😃
The text was updated successfully, but these errors were encountered: