RC0 Injecting Custom Scripts

I used a similar solution as well. Got to finally work how I wanted as well. I was wanting to copy a enviroment configuration file that changes depending on using ionic serve vs ionic build platform. That way I can dynamically change the api url’s. For others the following solution below will also work:

package.json

"scripts": {
"build": "ionic-app-scripts build --dev --copy ./config/production.js",
"watch": "ionic-app-scripts watch --copy ./config/development.js",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
 },

config/production.js

module.exports = {
  include: [
  {
    src: 'src/assets/',
    dest: 'www/assets/'
   },
  {
      src: 'src/index.html',
      dest: 'www/index.html'
  },
  {
    src: 'node_modules/ionic-angular/polyfills/polyfills.js',
    dest: 'www/build/polyfills.js'
  },
  {
    src: 'node_modules/ionicons/dist/fonts/',
    dest: 'www/assets/fonts/'
   },
   {
      src: 'config/config.production.ts',
      dest: 'src/config/config.ts'
    }
  ]
};

So my copy script just appends my config.ts file into the proper folder. The development version (config.development.js) will copy the file config/config.dev.ts to src/config/config.ts. I then am importing the config.ts file into my providers.

Both solutions works for either injecting scripts into your build like your version, or having a method for dynamically changing build files depending on the target.
`

1 Like