# Overriding Webpack configuration
In some rare cases you may find the need to tweak or override the webpack configuration used by the CLI. 
The CLI will pick up any `webpack.config.js` in your project root folder and merge it with it's own.

The configs are loaded and merged in the following order:
1. internal CLI configuration
2. from optional webpack.config.js file in project folder

The file has to export a function. The function is invoked with the base config and a context object.

```javascript
const { merge } = require('lodash');

// config: base config used by CLI
// context: helper functions
module.exports = (config, context) => {

    if( context.isCommand('build') )
        return merge( {}, config, myBuildConfig);

    if( context.isCommand('start'))
        return {
            ...config,
            devtool: 'source-map'
        };

    return config;
};
```

### The CLI build context

The CLI context is passed along build tasks and steps. The object is only accessible during build time. 

```typescript
    // Returns the root project path.
    getRootPath(...paths: string[]): string;
    // Returns the path to the source files.
    getSourcePath(...paths: string[]): string;
    // Returns the path to the output directory.
    getDistPath(...paths: string[]): string;
    // Returns the path to the CLI itself.
    getCliPath(...paths: string[]): string;
    // Returns the path to the locale files.
    getLocalePath(...paths: string[]): string;

    // Returns true if the given command(s) where used with the CLI.
    isCommand(...names:string[]): boolean;

    // Returns true if in production environment.
    // Either by NODE_ENV === 'production' or ENV === 'prod'
    isProduction(): boolean;

    // Returns true if the environment variable ENV equals 'prod'.
    isProdEnv(): boolean;
    // Returns true if the environment variable ENV equals 'qa'.
    isQaEnv(): boolean;
```