AccordBox / python-webpack-boilerplate

Django Webpack boilerplate & Flask Webpack boilerplate
https://python-webpack-boilerplate.rtfd.io
MIT License
167 stars 20 forks source link

Multiple javascript_pack-tags trigger second script twice #7

Closed RedCore161 closed 3 years ago

RedCore161 commented 3 years ago

Problem I have a body.html which uses {% javascript_pack 'main-bundle' attrs='charset="UTF-8"' %}

and a detail.html which uses {% javascript_pack 'detail' attrs='charset="UTF-8"' %} it also extends with {% extends 'body.html' %}

This causes 'detail.js' to be called twice.

It works if i use {% javascript_pack 'main-bundle' 'detail' attrs='charset="UTF-8"' %} in body.html, but now i load unnessessary js-code.

Reproduce Use this: {% javascript_pack 'main-bundle' attrs='charset="UTF-8"' %} {% javascript_pack 'detail' attrs='charset="UTF-8"' %} with simple debug line each: console.log("DEBUG-"+(new Date()).getTime()); You will see 3 console-lines instead of 2.

Question Am i supposed to only use javascript_pack once?

michael-yin commented 3 years ago

@RedCore161

The javascript_pack API is inspired from Rails webpacker project.

https://github.com/rails/webpacker/blob/master/lib/webpacker/helper.rb#L134-L155

Thx.