import type { Configuration as WebpackConfig, RuleSetLoader } from 'webpack'; import type { Configuration as DevServerConfig } from 'webpack-dev-server'; import type { TransformOptions as BabelOption } from '@babel/core'; import type { ProcessOptions as PostcssProcessOptions, Plugin as PostcssPlugin } from 'postcss'; import type { StyleResourcesLoaderOptions } from 'style-resources-loader'; import type HTMLWebpackPlugin from 'html-webpack-plugin'; import type { MonitorOptions } from '@deppon/deppon-monitor-browser'; import type { UserConfig as CSSOptions } from '@unocss/core'; interface MultiEntryItemOptions { /** 入口文件路径 */ entry: string; /** 入口文件对应的 html 模板路径,或者传入自定义的 HTMLWebpackPlugin 配置 */ htmlTemplate: string | HTMLWebpackPlugin.Options; } export interface ErrorMonitorOptions extends MonitorOptions { /** * 上传 sourcemap 的目录 * @default 'dist' */ dir?: string; /** * 默认开发环境不启用,即 `process.env.NODE_ENV` 为 `development` 时 * * 开始 `debug` 模式后,开发环境也会强制开启,仅用于调试时 * @default false */ debug?: boolean; } interface IStaticCacheBuild { open: boolean; // 是否开启离线资源缓存构建 resourcePrefixPrefix: string; //项目前缀 projectNam: string; envs?: Array; // 接口环境配置不需要 https wxNotice?: string; // 企业微信机器人 hooks url htmlPathMap: any; } export interface DepponScriptsConfig { /** * 入口文件路径 * * !!! 无论什么格式,都会自动为每个入口添加 @babel/polyfill,请勿手动添加 * * 如果传入的是字符串或者数组,代表单入口 * * 如果传入的是对象,代表多入口打包 * * 默认多入口使用同一个 html 模板 * * 如果对象属性的值为对象,则可以提供 htmlTemplatePath,为每个入口配置不同的 html 模板(自动生成 htmlWebpackPlugin) * @default 'src/index.(j|t)sx?' */ entry?: string | string[] | Record; /** * html 模板路径,默认在 `public/index.html` 中,或者传入自定义的 HTMLWebpackPlugin 配置 * @default 'public/index.html' */ htmlTemplatePath?: string | HTMLWebpackPlugin.Options | HTMLWebpackPlugin.Options[]; /** * 打包目录名 * @default 'dist' */ buildDir?: string; /** * 公共路径 * @default '/' */ publicPath?: string; /** * 是否开启生产环境 sourcemap * @default false */ sourcemap?: boolean; /** * 开发服务器 server 配置 */ devServer?: DevServerConfig; /** * babel 配置,默认配置已经支持 vue + ts 环境,如果需要额外配置,会自动合并 */ babel?: BabelOption; /** * 自定义 js 编译器,设置后,会禁用默认的 babel 编译器 * * 可传入 webpack loader 配置 */ customJsLoader?: RuleSetLoader; /** * postcss 配置,默认配置了 autoprefixer 插件,如果需要额外配置,会自动合并 */ postcss?: PostcssProcessOptions & { plugins?: PostcssPlugin[]; }; /** * 是否禁用打包文件 size 输出信息 * @default true */ disabledBundleSize?: boolean; /** * 路径别名 */ alias?: { [key: string]: string }; /** * less 变量 */ modifyVars?: { [key: string]: string }; /** * 自定义 webpack 配置,需返回新的完整配置 */ webpack?: (config: WebpackConfig) => WebpackConfig; styleResourcesLoaderOptions?: StyleResourcesLoaderOptions; /** * 构建时是否单独拆分 cbk 组件包 * @default false */ splitCBKComponents?: boolean; /** * 是否开启错误监控 * @default false */ errorMonitor?: ErrorMonitorOptions; staticCacheBuild: IStaticCacheBuild; /** * 是否启用 unocss * @default false */ unocss?: CSSOptions | boolean; } export function defineConfig(config: DepponScriptsConfig): DepponScriptsConfig;