Answer the question
In order to leave comments, you need to log in
How to replace a variable during application build?
Hi
When developing a project locally, I bind to an api that is running on the local host, when I build and upload the application, I need to replace this address with the real api address, is there a way to automate this, for example, to replace a variable during npm run build?
Thanks
Answer the question
In order to leave comments, you need to log in
1. npm i gulp-replace
2. replace -> inside task that builds js
If you are using your build:
module.exports = {
plugins: [
new webpack.DefinePlugin({
__API__: JSON.stringify('http://my-api-service.com'),
}),
],
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question