App-scripts: Custom copy.config for conditionally copying files?


#1

Greetings,

I’m trying to create a custom copy.config.js file that copies files only in development mode (i.e. not when --prod is called). Anyone have a clue on how to conditionally copy files?

I’m currently looking at the copy source now but not seeing any hooks (and there is not a lot of documentation at this time).

Or is there another way to do this? Conditionally set the custom copy.config.js file?

Leif


#2

I figured out the answer myself and thought I should share it here.

The copy.config.js file is a JavaScript file (I was thinking it was a JSON file), so all that is required to check if you are in prod or dev build mode is to place your module.export statements inside an if statement which tests the environment variable:

if( process.env.IONIC_ENV === 'prod' ){
     module.exports = {
          // ADD PROD-ONLY OBJECTS HERE
     }
}else{
      module.exports = {
          // ADD DEV-ONLY OBJECTS HERE
     }
}

At least that is how I am solving my problem.

Leif