mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
@grafana/toolkit: webpack extend TS→JS (#21176)
This commit is contained in:
parent
06347e3f86
commit
7aeba652c9
@ -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?
|
||||
|
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
const {cloneDeep} = require('lodash');
|
||||
|
||||
const overrideWebpackConfig = (originalConfig, options) => {
|
||||
const config = cloneDeep(originalConfig);
|
||||
config.name = 'customConfig';
|
||||
return config;
|
||||
};
|
||||
|
||||
module.exports = overrideWebpackConfig;
|
@ -1,10 +0,0 @@
|
||||
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;
|
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
const {cloneDeep} = require('lodash');
|
||||
|
||||
module.exports.getWebpackConfig = (originalConfig, options) => {
|
||||
const config = cloneDeep(originalConfig);
|
||||
config.name = 'customConfig';
|
||||
return config;
|
||||
};
|
@ -1,8 +0,0 @@
|
||||
import { CustomWebpackConfigurationGetter } from '../../../webpack.plugin.config';
|
||||
import _ from 'lodash';
|
||||
|
||||
export const getWebpackConfig: CustomWebpackConfigurationGetter = (originalConfig, options) => {
|
||||
const config = _.cloneDeep(originalConfig);
|
||||
config.name = 'customConfig';
|
||||
return config;
|
||||
};
|
@ -1,7 +1,5 @@
|
||||
/* WRONG CONFIG ON PURPOSE - DO NOT COPY THIS */
|
||||
|
||||
const config = {
|
||||
module.exports.config = {
|
||||
name: 'test',
|
||||
};
|
||||
|
||||
export = 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);
|
||||
|
Loading…
Reference in New Issue
Block a user