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

seems it doesn't work in Vite 4.0.0 #34

Open
qinhua opened this issue Jul 7, 2023 · 1 comment
Open

seems it doesn't work in Vite 4.0.0 #34

qinhua opened this issue Jul 7, 2023 · 1 comment

Comments

@qinhua
Copy link

qinhua commented Jul 7, 2023

I added the following code to index.html, but it did not take effect

<!-- Hotjar Tracking Code -->
  <link vite-if="<{ VITE_APP_ENV }> === prod" rel="preconnect" href="https://static.hotjar.com" />
  <script vite-if="<{ VITE_APP_ENV }> === prod">
    ; (function (h, o, t, j, a, r) {
      h.hj =
        h.hj ||
        function () {
          ; (h.hj.q = h.hj.q || []).push(arguments)
        }
      h._hjSettings = { hjid: xxxxx, hjsv: 6 }
      a = o.getElementsByTagName('head')[0]
      r = o.createElement('script')
      r.async = 1
      r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv
      a.appendChild(r)
    })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=')
  </script>
@sunhak-hout
Copy link

Just in case anyone facing the same issue, Vite added support for HTML Env Replacement since v4.2.0. Without the need to install extra dependencies, check this out https://vitejs.dev/guide/env-and-mode.html#html-env-replacement

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

2 participants