Home

Issue: 2972

can't set `head.script.src` to env var inside `nuxt.config.js` file

[issue link]

In my nuxt.config.js file I insert a JS file into my site using the head attribute. I set the src of the file to an env var (process.env.FILE_URL) but can’t seem to get this working. I am seeing the following behaviour:

  1. When running nuxt dev the env var value is injected correctly and the correct file is loaded.
  2. When running nuxt build && nuxt start the value is not injected and I get undefined.
  3. If I set the src attr to be an immediately executing function which console logs and then returns process.env.FILE_URL, the console log is the correct value, but the src is still set to undefined.

Is this something anyone has seen or can help me with? I can’t find any documentation about whether this is expected behaviour, or a bug.

This question is available on Nuxt.js community (#c2579)