I am working on an ES6 AngularJS project where I am using webpack to bundle everything into dist/app.js
.
The CI/CD stack I am working with is SCM - Jenkins - Octopus:
Updates to my code are pushed to a repository
Jenkins clones the repository, calls
npm install
andgulp
which usesgulp-webpack
to bundle & minify everything from one entry point and puts it todist/app.js
- Post-build, Jenkins packages the app into a nuget pkg and pushes it to Octopus Deploy where the app is deployed to IIS
The octopus project is working in multiple environments and I have to have a way to replace some configuration variables depending on the environment. For that, Octopus provides a "Substitute variables in files" deployment steps.
When I didn't use a module bundler and ES6, I would just have a configuration file that sets some angular constants which I then used. I would have a config.js
file and a config.template.js
file. Octopus would replace the variables in the config.template.js
file and I would just set it to replace config.js
with config.template.js
post-deployment.
Now however, I am just using a plain config.js
that exports the variables I need to use, which I then import in the files where it is relevant (like a file that contains an angular controller function).
With this setup, I cannot do the substitution the same way I did it before, because my config.js
will just get included inside dist/app.js
. could anyone help me come up with a strategy on how to achieve this ? I was thinking to do the config.js
- config.template.js
swap before the build and then make Octopus replace the variables in the whole app.js
bundle but that seems rather inefficient.