I'm now working on sapui5 project managed by ui5.yaml & @ui5/cli. I don't know how to use something like .env to control some variables' value which can be switched between dev env and pro env.
And i have found a workaround, which creating a env.js and include it into controller file. So i can change some value by editing the env.js file. And now i want to make it more convenient.
I use @ui5/cli ui5 run build to build the project. And there is a configuration for custom tasks. And there is a task called webide-extension-task-copyFile which used to copy the /xs-app.json.
And now i create three env files which named as env-dev.js env-pro.js env.js. And i want to copy the env-pro into the env.js before it is built. And copy the env-dev into env.js when i run the ui5 run serve.
I have the config in ui5.yaml like this
specVersion: '2.4'
metadata:
name: ui
type: application
framework:
name: SAPUI5
....
customTasks:
....
- name: webide-extension-task-copyFile
afterTask: webide-extension-task-resources
configuration:
srcFile: '/webapp/env/env-pro.js'
destFile: '/webapp/env/env.js'
I'm sure the task has been triggered, but the file content hasn't been changed. So could someone can help me, or has another idea or success example about using the env in ui5 project.
Thank you :)