No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Help
    5
    6
    1550
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Diferno last edited by

      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: {
        env: ctx.dev
          ? { // so on dev we'll have
            GTM: '"GTM-XXDEV"'
          }
          : { // and on build (production):
            GTM: '"GTM-XXPROD"'
          }
      }
      

      And in the html I’m tying with:

      <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
          new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
          j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
          'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(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!

      1 Reply Last reply Reply Quote 1
      • rstoenescu
        rstoenescu Admin last edited by

        Hi,

        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 %>

        1 Reply Last reply Reply Quote 2
        • D
          Diferno last edited by

          Thx a lot!

          1 Reply Last reply Reply Quote 0
          • matroskin
            matroskin last edited by

            Now it works?

            vesteves 1 Reply Last reply Reply Quote 0
            • vesteves
              vesteves @matroskin last edited by

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

              <%= htmlWebpackPlugin.options.process.env.GOOGLE_RECAPTCHA_SITE %>
              
              1 Reply Last reply Reply Quote 0
              • Y
                yhu420 last edited by

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

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post