Replace an app config file with another before building app

Hello everyone, I am trying to get my gitlab-ci.yml file to replace a config file with another during build. The idea is to pick the right config file for each environment, straight from my Yaml.

Let me explain: I have config files in my app, under /lib/core/config. I would like to replace config.dart with firebase_config.dart if I am pushing to staging. I tried this rather clumsy way, which did not work :

webdev-build:
  image: google/dart:latest
  stage: build
  cache:
    paths:
      - .dart_tool/
  before_script:
    - cp $CI_PROJECT_DIR/lib/core/config/config_firebase.dart $CI_PROJECT_DIR/lib/core/config/config.dart
  script:
    - pub global activate webdev
    - pub get    
    - pub global run webdev build -o web:build
  artifacts:
    paths:
      - build
  only:
    - dev

I also tried to start with a simple job instead of the before_script statement.

In both cases the build process always crashes because config_firebase.dart cannot be found.

My understanding is that Gitlab CI first clones my repo to another, and creates a container environment, which will be used to build my app. It would imply that my attempt at solving the problem occurs too late.

What would be the correct way to achieve this ?