import type { ArrayOrNot, ChainedConfig, FileFilterUtil } from '../utils'; import type { DevServerOptions, BabelTransformOptions, BabelConfigUtils } from '@modern-js/types'; import type { AutoprefixerOptions, SassLoaderOptions, LessLoaderOptions, PugOptions, ForkTSCheckerOptions, PostCSSLoaderOptions, PostCSSPlugin, CSSLoaderOptions, StyleLoaderOptions, CssMinimizerPluginOptions } from '../thirdParty'; import { BundlerChain } from '../bundlerConfig'; import { ModifyBundlerChainUtils } from '../hooks'; /** html-rspack-plugin is compatible with html-webpack-plugin */ export type { Options as HTMLPluginOptions } from 'html-webpack-plugin'; export type ToolsDevServerConfig = ChainedConfig; export type ToolsAutoprefixerConfig = ChainedConfig; export type ToolsSassConfig = ChainedConfig; export type ToolsLessConfig = ChainedConfig; export type ToolsBundlerChainConfig = ArrayOrNot<(chain: BundlerChain, utils: ModifyBundlerChainUtils) => void>; export type ToolsBabelConfig = ChainedConfig; export type ToolsPugConfig = true | ChainedConfig; export type ToolsTSCheckerConfig = ChainedConfig; export type ToolsPostCSSLoaderConfig = ChainedConfig void; }>; export type ToolsCSSLoaderConfig = ChainedConfig; export type ToolsStyleLoaderConfig = ChainedConfig; export type ToolsMinifyCssConfig = ChainedConfig; export interface SharedToolsConfig { /** * Configure bundler config base on [webpack-chain](https://github.com/neutrinojs/webpack-chain) */ bundlerChain?: ToolsBundlerChainConfig; /** * Modify the config of [autoprefixer](https://github.com/postcss/autoprefixer) */ autoprefixer?: ToolsAutoprefixerConfig; /** * Modify the options of DevServer. */ devServer?: ToolsDevServerConfig; /** * Modify the options of [babel-loader](https://github.com/babel/babel-loader) * * When `tools.babel`'s type is Function,the default babel config will be passed in as the first parameter, the config object can be modified directly, or a value can be returned as the final result. * * When `tools.babel`'s type is `Object`, the config will be shallow merged with default config by `Object.assign`. * * Note that `Object.assign` is a shallow copy and will completely overwrite the built-in `presets` or `plugins` array, please use it with caution. */ babel?: ToolsBabelConfig; /** * Modify the options of [css-loader](https://github.com/webpack-contrib/css-loader). */ cssLoader?: ToolsCSSLoaderConfig; /** * Modify the options of [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin). */ minifyCss?: ToolsMinifyCssConfig; /** * Modify the options of [postcss-loader](https://github.com/webpack-contrib/postcss-loader). */ postcss?: ToolsPostCSSLoaderConfig; /** * Configure the [Pug](https://pugjs.org/) template engine. */ pug?: ToolsPugConfig; /** * Modify the options of [style-loader](https://github.com/webpack-contrib/style-loader). */ styleLoader?: ToolsStyleLoaderConfig; /** * Modify the options of [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin). */ tsChecker?: ToolsTSCheckerConfig; } export interface NormalizedSharedToolsConfig extends SharedToolsConfig { tsChecker: ToolsTSCheckerConfig; }