Insert hashed bundle URLs into static pug templates
Asked Answered
G

0

9

I'm using Webpack pug-html-loader + file-loader to generate a bunch of static pug templates.

I also want to start added hashed bundle filenames, but I cant work out how to insert the hashed filenames into all my pug templates

This is how I'm referencing my bundle currently in all the pug templates:

script(src="bundle.js")
link(href="bundle.css")

How would I modify that to reference bundle-[chunkhash].js/bundle-[chunkhash].css] - do I need to pass some variables to the pug-html-loader in webpack.config.js?

Note: I'm using the extract-text-plugin to output my SASS to a .css bundle file

Grouch answered 22/2, 2017 at 23:31 Comment(2)
I don't know what's the right way to solve your question. I normally use html-webpack-plugin to inject the script and css to my index.html file. It support custom template tooRapt
Ah, ye I looked at html-webpack but that doesnt seem to fit into the multiple pug template scenario I have going on. Thanks for the help though :)Grouch

© 2022 - 2024 — McMap. All rights reserved.