Could not build a production release for android

I am trying to build a production up with this command:

ionic build android --prod

However it fails with the error below:

@HOME ~/***/***-app(master)$ ionic build ios --prod

> ***-app@ ionic:build /Users/evgeny/***/***-app
> ionic-app-scripts build "--prod"

[18:26:09]  ionic-app-scripts 1.0.0
[18:26:09]  build prod started ...
[18:26:09]  clean started ...
[18:26:09]  clean finished in 1 ms
[18:26:09]  copy started ...
[18:26:09]  ngc started ...
[18:26:19]  ngc finished in 10.06 s
[18:26:19]  rollup started ...
[18:26:20]  rollup failed: Could not resolve entry (undefined/app/main.prod.ts)
[18:26:20]  ionic-app-script task: "build"
[18:26:20]  Error: Could not resolve entry (undefined/app/main.prod.ts)
Error: Could not resolve entry (undefined/app/main.prod.ts)
    at /Users/evgeny/***/***-app/node_modules/rollup/dist/rollup.js:8693:28

Any idea why?

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.5
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.0.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.11
OS: macOS Sierra
Node Version: v6.9.3
Xcode version: Xcode 8.2.1 Build version 8C1002

The problem is with custom rollup.config.js that had the following lines:

if (process.env.IONIC_ENV == 'prod') {
  // production mode
  rollupConfig.entry = '{{TMP}}/app/main.prod.ts';
  rollupConfig.sourceMap = false;
}