12345678910111213141516171819202122232425262728293031323334353637383940 |
- // Set the `ENV` global variable to be used in the app.
- var path = require('path');
- var webpack = require('webpack');
- var projectRootDir = process.env.IONIC_ROOT_DIR;
- var appScriptsDir = process.env.IONIC_APP_SCRIPTS_DIR;
- var env = process.env.NODE_ENV || 'dev';
- var config = require(path.join(appScriptsDir, 'config', 'webpack.config.js'));
- var envVars;
- if(process.env.IONIC_ENV === 'prod'){
- config = config["prod"];
- } else {
- config = config["dev"];
- }
- try {
- envVars = require(path.join(projectRootDir,'src', 'environments', env + '.json'));
- } catch(e) {
- envVars = {};
- }
- config.plugins = config.plugins || [];
- config.plugins.push(
- new webpack.DefinePlugin({
- ENV: Object.assign(envVars, {
- environment: JSON.stringify(env.trim())
- })
- })
- );
- if(env === 'prod') {
- // This helps ensure the builds are consistent if source hasn't changed:
- config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
- }
- module.exports = config;
|