Commit 7aeba652 by Steven Vachon Committed by Ryan McKinley

@grafana/toolkit: webpack extend TS→JS (#21176)

parent 06347e3f
......@@ -129,23 +129,20 @@ Currently we support following Jest configuration properties:
### How can I customize Webpack rules or plugins?
You can provide your own webpack configuration.
Provide a function implementing `CustomWebpackConfigurationGetter` in a file named `webpack.config.ts`.
Provide a function implementing `CustomWebpackConfigurationGetter` in a file named `webpack.config.js`.
You can import the correct interface and Options from `@grafana/toolkit/src/config`.
Example
``` ts
import { CustomWebpackConfigurationGetter } from '@grafana/toolkit/src/config'
```js
import CustomPlugin from 'custom-plugin';
const getWebpackConfig: CustomWebpackConfigurationGetter = (defaultConfig, options) => {
export const getWebpackConfig = (defaultConfig, options) => {
console.log('Custom config');
defaultConfig.plugins.push(new CustomPlugin())
return defaultConfig;
}
export = getWebpackConfig;
};
```
### How can I style my plugin?
......
'use strict';
const {cloneDeep} = require('lodash');
const overrideWebpackConfig = (originalConfig, options) => {
const config = cloneDeep(originalConfig);
config.name = 'customConfig';
return config;
};
module.exports = overrideWebpackConfig;
import { CustomWebpackConfigurationGetter } from '../../../webpack.plugin.config';
import _ from 'lodash';
const overrideWebpackConfig: CustomWebpackConfigurationGetter = (originalConfig, options) => {
const config = _.cloneDeep(originalConfig);
config.name = 'customConfig';
return config;
};
export = overrideWebpackConfig;
'use strict';
const {cloneDeep} = require('lodash');
module.exports.getWebpackConfig = (originalConfig, options) => {
const config = cloneDeep(originalConfig);
config.name = 'customConfig';
return config;
};
import { CustomWebpackConfigurationGetter } from '../../../webpack.plugin.config';
import _ from 'lodash';
export const getWebpackConfig: CustomWebpackConfigurationGetter = (originalConfig, options) => {
const config = _.cloneDeep(originalConfig);
config.name = 'customConfig';
return config;
};
......@@ -235,7 +235,7 @@ const getBaseWebpackConfig: WebpackConfigurationGetter = async options => {
export const loadWebpackConfig: WebpackConfigurationGetter = async options => {
const baseConfig = await getBaseWebpackConfig(options);
const customWebpackPath = path.resolve(process.cwd(), 'webpack.config.ts');
const customWebpackPath = path.resolve(process.cwd(), 'webpack.config.js');
try {
await accessPromise(customWebpackPath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment