Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

custom config files not working for PROD #25

Closed
shlomiassaf opened this issue Sep 25, 2016 · 7 comments
Closed

custom config files not working for PROD #25

shlomiassaf opened this issue Sep 25, 2016 · 7 comments

Comments

@shlomiassaf
Copy link
Contributor

Hi,

When setting the path to a config file in the package.json or using arguments in PROD mode the resolved file is always the default version of the config.

in runBundle:

  const taskInfo = (options.isProd) ? ROLLUP_PROD_TASK_INFO : ROLLUP_TASK_INFO;
  rollupConfig = fillConfigDefaults(context, rollupConfig, taskInfo);

The task is identified as PROD and sent to fillConfigDefaults.

fillConfigDefaults will load the configuration files using getConfigFileData (util.ts)

getConfigFileData(task.fullArgConfig, task.shortArgConfig, task.envConfig, null, context) || {};

Now, let's assume using config values from package.json (env). There is not way to distinguish between prod / dev in the config section so the end result is always loading xxx.config.js and not xxx.prod.config.js. getConfigFileData does not implement prod/dev file selection.

Since config inside package.json is not aware of prod/dev modes you probably need to decide on a convention to load files based on configuration preset. Something like add .prod for prod etc...

@strictd
Copy link

strictd commented Sep 25, 2016

You could pass your production config file in with command line arguments
--rollup ionic-rollup-prod.config.js

the other option would be to update src/bundle.ts line 159 to something like envConfig: 'ionic_rollup_prod',

@shlomiassaf
Copy link
Contributor Author

@strictd the 1st option, using arguments, will probably work but I prefer using the config object.

Yes, explicitly looking for ionic_rollup_prod can be added to the code but then a user will need to do that for every config file, this is not ideal.

I think a convention should take place and having 1 config file with added convention name.

@strictd
Copy link

strictd commented Sep 26, 2016

are you looking for prod configs for all ionic-app-script configs or just the rollup config? There is a rollup.prod.config.js file that the bundler defaults to on production builds.

@shlomiassaf
Copy link
Contributor Author

shlomiassaf commented Sep 26, 2016

@strictd I know there is a rollup.prod.config in the package, that's the point of this issue - being able to override it.

@strictd
Copy link

strictd commented Sep 26, 2016

I see your point.. Originally my thought was you wanted a complete second set of config files for prod. Which could be useful past the rollup configs for reasons nobody has thought of yet.

@adamdbradley
Copy link
Contributor

We're not using a single rollup config file: https://github.com/driftyco/ionic-app-scripts/blob/master/config/rollup.config.js#L56

Within the configs you can now check for: process.env.IONIC_ENV == 'prod'

@kleeb
Copy link

kleeb commented Oct 6, 2016

doing npm run build or ionic build goes production

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants