itgalaxy / nunjucks-webpack-plugin

A webpack plugin for nunjucks.
MIT License
27 stars 12 forks source link

Add ability to pass hash/contenthash templates #5

Closed aendra-rininsland closed 5 years ago

aendra-rininsland commented 7 years ago

Currently there doesn't seem to be a way of passing Webpack's filename hash/contenthash to the templates, which means it's more difficult to revision files for long-term storage.

A workaround might be to find/replace on the compiled HTML files, but really this step should probably be done at the time of template creation via nunjucks-webpack-plugin.

alexander-akait commented 7 years ago

@aendrew can your provide more information (use case, problem and etc)? Your want to use [hash] (and etc) features?

aendra-rininsland commented 7 years ago

@evilebottnawi Pretty much — my use case is that I use nunjucks-webpack-plugin to generate static HTML templates from Nunjucks templates, and unlike html-webpack-plugin, it seems nothing is added to the context that allows you to manually configure script tags so that they used the hashed filenames created by Webpack if you specify [hash] or [chunkhash] in the output filename.

For example, this is how html-webpack-plugin exposes templating globals that let you to specify how to load various hashed chunks.

alexander-akait commented 7 years ago

@aendrew your use html-webpack-plugin and want to integrate this plugin with html-webpack-plugin? Or only add ability to use [hash] (and etc). Anyway PR welcome :+1:

aendra-rininsland commented 7 years ago

@evilebottnawi No, I use nunjucks-webpack-plugin for generating HTML because I have a boatload of templates that are in Nunjucks that I need to render (AFAICT there isn't any way to use Nunjucks with html-webpack-plugin).

Will do a PR in a bit.

burt202 commented 5 years ago

Raised PR for supplying compilation.hash to templates. See https://github.com/itgalaxy/nunjucks-webpack-plugin/pull/13

burt202 commented 5 years ago

@evilebottnawi can you tag and publish the next version please?

alexander-akait commented 5 years ago

@burt202 Done in https://github.com/itgalaxy/nunjucks-webpack-plugin/releases/tag/5.0.0, can we close issue?

burt202 commented 5 years ago

Im happy for it to be closed. What about @aendrew ?

aendra-rininsland commented 5 years ago

Haven't had time to test but this seems like it should totally do what I'm needing. Thank you! 👍