How to get process.env.GTM in index.template.html?

  • Hi!
    I’m using vue-gtm plugin, and want to use different tags for dev and production.
    Currently I’m putting them in the quasar.conf file as shown in the documentation. But can’t figure out how to capture them in the html:

    build: {
        ? { // so on dev we'll have
          GTM: '"GTM-XXDEV"'
        : { // and on build (production):
          GTM: '"GTM-XXPROD"'

    And in the html I’m tying with:

        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
      })(window,document,'script','dataLayer','<%= htmlWebpackPlugin.GTM %>');</script>

    Already tryed with:
    <%= htmlWebpackPlugin.env.GTM %>
    <%= htmlWebpackPlugin.process.env.GTM %>
    <%= process.env.GTM %>

    But with the same awful result 😞
    Thx in advance!

  • Admin


    Just added a commit for this functionality. Will be available in v0.17 (no worries, just a simple breaking change on a prop on QLayoutDrawer).
    It will work as <%= htmlWebpackPlugin.process.env.GTM %>

  • Thx a lot!

  • Now it works?

  • @matroskin yep.
    But now, you need to put OPTIONS before the PROCESS like this.

    <%= htmlWebpackPlugin.options.process.env.GOOGLE_RECAPTCHA_SITE %>

  • As an update for those wondering, I got it working simply using <%= process.env.GOOGLE_CLIENT_ID %>

Log in to reply