0

My company is still using Sitecore v8.2 and for a while we are not upgrading it.

Is there a way to add a script that has been created Front End side using Webpack and that has the following structure <file_name>.<random_generated_string>.bundle.js, where the "random_generated_string" is created at building time, when the solution is building the Front End stuff using Webpack, and add it to the Sitecore layout with the correct name each time there is a new build?

For example, when there is the first build on the Sitecore layout page I would like Sitecore to add the following script automatically:

...
<script src="~/FrontEnd/dist/js/index.57457932.bundle.js"></script>
...

But then in the next build I would like that Sitecore will add the new built Front End script:

...
<script src="~/FrontEnd/dist/js/index.99527463.bundle.js"></script>
...

Is it possible to do the same also with the styles that Webpack create as well and add the resulting file to the head of the layout page?

...
<link href="~/FrontEnd/dist/css/main.99527463.bundle.css" rel="stylesheet">
...
2
  • Change the webpack generation to remove the random string. If its there as a cache breaker, there are easier ways of doing that via adding a query string to the link ref in your code.
    – Richard Seal
    Jan 6, 2021 at 16:22
  • @RichardSeal Thanks for your reply, the meaning of that string is exactly the one you are mentioning. To let me understand better your suggestion, you are saying to add a query string using Sitecore, isn't it? How can I do that?
    – Ferie
    Jan 7, 2021 at 10:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.