Skip to content

Commit

Permalink
fix: add cacheBuster in devmode
Browse files Browse the repository at this point in the history
This will fix a bug in react-native WebView where the
static assets are never updated.
With the cache busting in dev mode only,
the webview will refetch the files everytime
  • Loading branch information
acezard committed Apr 12, 2023
1 parent ccf8fcd commit 1cb05a7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/targets/browser/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, viewport-fit=cover">
<link rel="preload" href="//{{.Domain}}/assets/fonts/Lato-Bold.immutable.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="//{{.Domain}}/assets/fonts/Lato-Regular.immutable.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="//{{.Domain}}/assets/fonts/Lato-Bold.immutable.woff2" as="font" type="font/woff2"
crossorigin>
<link rel="preload" href="//{{.Domain}}/assets/fonts/Lato-Regular.immutable.woff2" as="font" type="font/woff2"
crossorigin>
<% _.forEach(htmlWebpackPlugin.files.css, function(file) { %>
<link rel="stylesheet" href="<%- file %>">
<% }); %>
<link rel="stylesheet" href="//{{.Domain}}/assets/fonts/fonts.css">
<link rel="stylesheet" href="//{{.Domain}}/assets/fonts/fonts.css">
{{.ThemeCSS}}
<% if (__STACK_ASSETS__) { %>
{{.CozyClientJS}}
Expand All @@ -30,8 +32,12 @@
data-cozy-icon-path="{{.IconPath}}" data-cozy-subdomain-type="{{.SubDomain}}"
data-cozy-default-wallpaper="{{.DefaultWallpaper}}" data-cozy-flags="{{.Flags}}">
<% _.forEach(htmlWebpackPlugin.files.js, function(file) { %>
<script src="<%- file %>"></script>
<% }); %>
<% if (process.env.NODE_ENV==='development' ) { %>
<script src="<%- file %>?cacheBuster=<%= Date.now() %>"></script>
<% } else { %>
<script src="<%- file %>"></script>
<% } %>
<% }); %>
</body>

</html>

0 comments on commit 1cb05a7

Please sign in to comment.