How to override default webpack configuration?

Here is the solution I found in Grafana toolkit readme.

You can provide your own webpack configuration.
Provide a function implementing CustomWebpackConfigurationGetter in a file named webpack.config.ts.

You can import the correct interface and Options from @grafana/toolkit/src/config.

Example:

import { CustomWebpackConfigurationGetter } from '@grafana/toolkit/src/config'
import CustomPlugin from 'custom-plugin';
const getWebpackConfig: CustomWebpackConfigurationGetter = (defaultConfig, options) => {
    console.log('Custom config');
    defaultConfig.plugins.push(new CustomPlugin())
    return defaultConfig;
}
export = getWebpackConfig;
2 Likes