Reputation: 1174
I have some trouble with webpack and my api url. I have a build with Jenkins who deploy my app on two server
I have two backend url (same as frontend url) :
My webpack config :
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
productionSourceMap: true,
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
bundleAnalyzerReport: process.env.npm_config_report
},
My prod.env file :
module.exports = {
NODE_ENV: '"production"',
URL_API: '"http://12.122.125.208/api/"',
};
It's possible to have dynamic URL based on current URL something like :
const = BASE_URL;
URL_API: BASE_URL + '/api/"',
With that, I can deploy one time for my two server
How can I do that?
Thanks.
Upvotes: 2
Views: 999
Reputation: 558
You could configure multiple Jenkins "Parameterized Builds", and have different profiles:
BASE_URL=12.122.125.208
BASE_URL=12.122.125.209
And then access this BASE_URL
from your webpack config using process.env.BASE_URL
.
Upvotes: 1