Skip to content
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

Problem when using cache busting hash #1

Open
wimdeblauwe opened this issue Oct 20, 2019 · 0 comments
Open

Problem when using cache busting hash #1

wimdeblauwe opened this issue Oct 20, 2019 · 0 comments

Comments

@wimdeblauwe
Copy link

I am using this plugin like this:

            new HtmlWebpackPlugin({
                template: '!!html-loader!' + path.resolve(ROOT, 'templates/home.html'),
                filename: "home.html",
                hash: true // enable cache busting
            }),
            new ThymeleafInjectWebpackPlugin(),

This generates the following HTML:

<html xmlns="http://www.w3.org/1999/xhtml"
      lang="en">
<head>
    <!-- CSS will be added here automatically by Webpack -->
    <title></title>
<link href="dist/application.css?13cab2fb84153b69b3cf" rel="stylesheet" th:href="@{dist/application.css?13cab2fb84153b69b3cf}"></head>
<body>
<h1>Test</h1>
<!-- JavaScript will be added here automatically by Webpack -->
<script type="text/javascript" src="application.bundle.js?13cab2fb84153b69b3cf" th:src="@{application.bundle.js?13cab2fb84153b69b3cf}"></script></body>
</html>

For the CSS, this works, but not for the JavaScript because Thymeleaf generates:

<script type="text/javascript" src="13cab2fb84153b69b3cf"></script></body>

To make it work, this:

th:src="@{application.bundle.js?13cab2fb84153b69b3cf}"

should be changed to:

th:src="@{./application.bundle.js?13cab2fb84153b69b3cf}"

This makes Thymeleaf generate:

<script type="text/javascript" src="./application.bundle.js?13cab2fb84153b69b3cf"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant