Pass environment variable into a Vue App at runtime

后端 未结 5 1382
孤街浪徒
孤街浪徒 2020-12-05 17:34

How can I access environment variables in Vue, that are passed to the container at runtime and not during the build?

Stack is as follows:

  • VueCLI 3.0.5
5条回答
  •  醉梦人生
    2020-12-05 18:21

    I got it to work with the solution proposed by @Hendrik M Halkow.

    But I stored the config.js in the static folder. By doing that, I don't have to care about not minifying the file.

    Then include it like this:

    
    

    and use this volume mount configuration:

    ...
    volumeMounts:
        - name: config-volume
          mountPath: /usr/share/nginx/html/static/config.js
          subPath: config.js
    

提交回复
热议问题