支持module.rules

This commit is contained in:
Pan Qiancheng 2024-12-08 13:21:58 +08:00
parent 165fba6628
commit 7afe4f9583
3 changed files with 18 additions and 1 deletions

View File

@ -293,6 +293,11 @@ module.exports = function (webpackEnv) {
type: 'javascript/auto',
use: [oakFileLoader('wxml')],
},
...(projectConfiguration &&
projectConfiguration.module &&
projectConfiguration.module.rules
? projectConfiguration.module.rules : []
),
],
},
plugins: [

View File

@ -9,6 +9,9 @@ type ExternalsType = Required<WebpackConfiguration>['externals'];
type ExternalsObjectType = Exclude<ExternalsType, RegExp | string | Function | Array<any>>;
type PluginType = Required<WebpackConfiguration>['plugins'];
type PluginInstanceType = PluginType extends Array<infer T> ? Exclude<T, false | number | string | null | undefined> : never;
type ModuleType = Required<WebpackConfiguration>['module'];
type RuleType = Required<ModuleType>['rules'];
type RuleObjectType = RuleType extends Array<infer T> ? Exclude<T, false | number | string | null | undefined> : never;
/**
*
*/
@ -23,6 +26,9 @@ export type CompilerConfiguration = {
cacheGroups: CacheGroups;
};
externals?: ExternalsObjectType;
module: {
rules: RuleObjectType[];
};
plugins?: PluginInstanceType[];
};
};

View File

@ -10,7 +10,10 @@ type CacheGroups = Exclude<SplitChunks, false>["cacheGroups"];
type ExternalsType = Required<WebpackConfiguration>['externals'];
type ExternalsObjectType = Exclude<ExternalsType, RegExp | string | Function | Array<any>>;
type PluginType = Required<WebpackConfiguration>['plugins'];
type PluginInstanceType = PluginType extends Array<infer T> ? Exclude<T, false| number | string | null | undefined> : never
type PluginInstanceType = PluginType extends Array<infer T> ? Exclude<T, false | number | string | null | undefined> : never
type ModuleType = Required < WebpackConfiguration > ['module'];
type RuleType = Required<ModuleType>['rules'];
type RuleObjectType = RuleType extends Array<infer T> ? Exclude<T, false | number | string | null | undefined> : never
/**
*
@ -26,6 +29,9 @@ export type CompilerConfiguration = {
cacheGroups: CacheGroups;
},
externals?: ExternalsObjectType;
module: {
rules: RuleObjectType[];
}
plugins?: PluginInstanceType[];
},
};