cristinafsanz
10/3/2019 - 1:24 PM

Add script end body nuxt

https://nuxtjs.org/guide/views#document

You can customize the HTML app template used by Nuxt.js to include scripts or conditional CSS classes.

<!-- app.html created in root project-->
<!DOCTYPE html>
<html {{ HTML_ATTRS }}>

<head>
  {{ HEAD }}
</head>

<body {{ BODY_ATTRS }}>

  {{ APP }}
  <script type="text/javascript">
    //<![CDATA[
    const tc_vars = {
      env_template: 'web',
      env_work: `{{ ENV.tagCommander }}`,
      env_language: 'en'
    }
    //]]>
  </script>
</body>

</html>
require('dotenv').config()

export default {
  mode: 'universal',
  env: {
    tagCommander: process.env.TAG_COMMANDER
  },

  /*
  ** Headers of the page
  */
  head: {
    title: pkg.name,
    htmlAttrs: {
      lang: 'en'
    },
    script: [
      {
        src:
          process.env.TAG_COMMANDER === 'prod'
            ? 'https://cdn.tagcommander.com/4113/tc_H4HInitiative_21.js'
            : 'https://cdn.tagcommander.com/4113/uat/tc_H4HInitiative_21.js',
        body: true
      }
    ]
  }
}