1

I am a complete noobie on the ionic/webpack build process, but for this task I am referring specifically to this: https://github.com/ionic-team/ionic-app-scripts#environments. I don't quite fully understand what is meant by "If the variable exists in the process environment it will be replaced with that value."

The scripts in my package.json are as follows:

"scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build --dev",
    "build:after": "",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
}

From what I understand, I should be able to set up an env variable, say process.env.BASE_URL for example, anywhere in my code that could be a different value depending on the build.

My question is how do I structure my script to set that variable in my process environment? Is it just a matter of setting the "build" script as "BASE_URL=myurl ionic-app-scripts build --dev"? And if it really is that easy, how would I then access the script for the --prod flag to set the variable for that one as well? Thank you in advance. I really love this community.

1 Answer 1

1

You're almost correct. Usually, the way that I do things is to define an item in my scripts config like "ionic:build:prod" : "BASE_URL=myurl ionic-app-scripts build --prod. That way you can run that whole thing with one easy command(npm run ionic:build:prod)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.