mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* fix: `multiple` type should be MultipleConfigurationMergeFunction * test: fix webpackMerge.multiple case * style: single queto
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { Configuration, HotModuleReplacementPlugin, Plugin } from 'webpack';
|
|
import webpackMerge = require('webpack-merge');
|
|
|
|
const a: Configuration = {
|
|
entry: 'test.js'
|
|
};
|
|
const b: Configuration = {
|
|
devtool: 'source-map'
|
|
};
|
|
|
|
const c: Configuration = webpackMerge(a, b);
|
|
const d: Configuration = webpackMerge.smart(a, b);
|
|
const e: Configuration[] = webpackMerge.multiple({a, b});
|
|
const f: Configuration = webpackMerge(
|
|
{
|
|
customizeArray(x: any[], y: any[], key: string): any[] | undefined {
|
|
if (key === 'extensions') {
|
|
return Array.from(new Set([...x, ...y]));
|
|
}
|
|
// Fall back to default merging
|
|
return undefined;
|
|
},
|
|
customizeObject(x: {}, y: {}, key: string): {} | undefined {
|
|
if (key === 'module') {
|
|
// Custom merging
|
|
return { ...x, ...y };
|
|
}
|
|
|
|
// Fall back to default merging
|
|
return undefined;
|
|
}
|
|
}
|
|
)(a, b);
|
|
const g: Configuration = webpackMerge({
|
|
customizeArray: webpackMerge.unique(
|
|
'plugins',
|
|
['HotModuleReplacementPlugin'],
|
|
(plugin: Plugin) => plugin.constructor && plugin.constructor.name
|
|
)
|
|
})({
|
|
plugins: [
|
|
new HotModuleReplacementPlugin()
|
|
]
|
|
}, {
|
|
plugins: [
|
|
new HotModuleReplacementPlugin()
|
|
]
|
|
});
|
|
const h: Configuration = webpackMerge.strategy(
|
|
{
|
|
entry: 'prepend', // or 'replace', defaults to 'append'
|
|
'module.loaders': 'prepend'
|
|
}
|
|
)(a, b);
|
|
const i: Configuration = webpackMerge.smartStrategy(
|
|
{
|
|
entry: 'prepend', // or 'replace'
|
|
'module.loaders': 'prepend'
|
|
}
|
|
)(a, b);
|