1

My Vue.js project is build and bundled with Webpack.

All i want to achieve is to inject external param e.g. backend_url from outside the dist ( like external file,cli param,whatever..) into the dist in deploy time.

It will help me to deploy the same dist into several environments

Iv'e looked into this answer - Exclude module from webpack minification but this doesn't help me becouse the answer just excludes from minification but still inject to values into the dist

Any suggest how to do that?

Community
  • 1
  • 1
yarin
  • 543
  • 1
  • 5
  • 18

1 Answers1

0

I'm not aware of a way to get an external module into the webpack context (post bundle compilation).

In the HTML where you include your Webpack bundle, you could include your "external params" javascript file first and store those parameters in global scope.

If you want to abstract the global scope, you could create a bundled module which proxies the global scope, and then always access those variables via the bundled module. This way, in future if you want to change the source of that data, you can do it in one place.

mikeapr4
  • 2,830
  • 16
  • 24