{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://jsonschema.ntnyq.com/project.schema.json",
  "title": "JSON schema for weapp project config",
  "description": "Configuration Schema for weapp project config",
  "type": "object",
  "definitions": {
    "array-of-match": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "类型",
            "$ref": "#/definitions/match-type"
          },
          "value": {
            "type": "string",
            "description": "路径或取值",
            "minLength": 1
          }
        },
        "required": ["type", "value"]
      }
    },
    "match-type": {
      "type": "string",
      "enum": ["file", "folder", "suffix", "prefix", "glob", "regexp"]
    },
    "minify-wxml-setting": {
      "type": "object",
      "properties": {
        "collapseWhitespace": {
          "type": "boolean",
          "description": "标签内所有连续空白符会被压缩成 1 个空格，换行的情况按 preserveLineBreaks 处理",
          "default": true
        },
        "conservativeCollapse": {
          "type": "boolean",
          "description": "默认标签前后不保留空格，为 true 时标签前后会保留一个空格(当有时)",
          "default": false
        },
        "preserveLineBreaks": {
          "type": "boolean",
          "description": "默认按 collapseWhitespace 处理，为 true 时所有换行都会被保留",
          "default": false
        }
      },
      "additionalProperties": false
    },
    "skeleton": {
      "type": "object",
      "description": "骨架屏配置",
      "properties": {
        "loading": {
          "type": "string",
          "description": "骨架屏动画",
          "default": "spin",
          "oneOf": [
            { "const": "shine", "description": "闪光" },
            { "const": "spin", "description": "旋转" },
            { "const": "chiaroscuro", "description": "明暗对比" }
          ]
        },
        "outline": {
          "type": "object",
          "description": "骨架屏外边框设置",
          "properties": {
            "remain": {
              "type": "boolean",
              "description": "是否保持边框颜色",
              "default": true
            },
            "replace": {
              "type": "string",
              "description": "remain 为 false 时替代 style.border"
            }
          },
          "additionalProperties": false
        },
        "text": {
          "type": "object",
          "description": "骨架屏文字设置",
          "properties": {
            "color": {
              "type": "string",
              "description": "骨架页面中文字块的的颜色，颜色值支持 16 进制"
            }
          },
          "additionalProperties": false
        },
        "image": {
          "type": "object",
          "description": "骨架屏图片设置",
          "properties": {
            "color": {
              "type": "string",
              "description": "骨架页面中被视为图片块的颜色"
            },
            "shape": {
              "type": "string",
              "description": "骨架页面中被视为图片块的形状",
              "oneOf": [
                { "const": "circle", "description": "圆形" },
                { "const": "rect", "description": "矩形" }
              ]
            },
            "shapeOpposite": {
              "type": "array",
              "description": "数组中每个元素是一个 DOM 选择器，用于选择 DOM 元素，被选择 DOM 的形状将和配置的 shape 形状相反",
              "items": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false
        },
        "button": {
          "type": "object",
          "description": "骨架屏按钮设置",
          "properties": {
            "color": {
              "type": "string",
              "description": "骨架页面中被视为按钮块的颜色"
            },
            "excludes": {
              "type": "array",
              "description": "DOM 选择器，用来选择元素，该数组中的元素将不被视为按钮块",
              "items": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false
        },
        "pseudo": {
          "type": "object",
          "description": "骨架屏伪元素块设置",
          "properties": {
            "color": {
              "type": "string",
              "description": "骨架页面中被视为伪元素块的颜色"
            },
            "shape": {
              "type": "string",
              "description": "来设置伪元素块的形状",
              "oneOf": [
                { "const": "circle", "description": "圆形" },
                { "const": "rect", "description": "矩形" }
              ]
            }
          },
          "additionalProperties": false
        },
        "excludes": {
          "type": "array",
          "description": "如果你有不需要进行骨架处理的元素，那么将该元素的 CSS 选择器写入该数组。",
          "items": {
            "type": "string"
          }
        },
        "remove": {
          "type": "array",
          "description": "不需要生成页面骨架，且需要从 DOM 中移除的元素，配置值为移除元素的 CSS 选择器。",
          "items": {
            "type": "string"
          }
        },
        "hide": {
          "type": "array",
          "description": "不需要移除，但是通过设置其透明度为 0，来隐藏该元素，配置值为隐藏元素的 CSS 选择器。",
          "items": {
            "type": "string"
          }
        },
        "empty": {
          "type": "array",
          "description": "该数组中元素是 CSS 选择器，被选择的元素将被清空子元素",
          "items": {
            "type": "string"
          }
        },
        "grayBlock": {
          "type": "array",
          "description": "该数组中元素是 CSS 选择器，被选择的元素将被被插件处理成一个色块，色块的颜色和按钮块颜色一致。内部元素将不再做特殊处理，文字将隐藏",
          "items": {
            "type": "string"
          }
        },
        "showNative": {
          "type": "boolean",
          "description": "是否显示原生组件，为 false 时原生组件被处理为 view",
          "default": false
        },
        "backgroundColor": {
          "type": "string",
          "description": "骨架屏背景色",
          "default": "transparent"
        },
        "mode": {
          "type": "string",
          "description": "模式",
          "default": "fullscreen",
          "oneOf": [
            { "const": "fullscreen", "description": "绝对定位占满全屏" },
            { "const": "auto", "description": "高度随内容撑开" }
          ]
        },
        "templateName": {
          "type": "string",
          "description": "骨架屏模板的 name 值",
          "default": "skeleton"
        },
        "cssUnit": {
          "type": "string",
          "description": "CSS单位",
          "default": "rpx",
          "enum": ["rpx", "rem", "vw", "vh", "vmin", "vmax"]
        },
        "decimal": {
          "type": "integer",
          "description": "生成骨架页面中 css 值保留的小数位数，默认值是 4",
          "minimum": 1,
          "default": 4
        }
      },
      "additionalProperties": false
    }
  },
  "properties": {
    "appid": {
      "type": "string",
      "description": "项目的 appid"
    },
    "cloudbaseRoot": {
      "type": "string",
      "description": "云开发代码根目录（需为相对路径）"
    },
    "cloudcontainerRoot": {
      "type": "string",
      "description": "云托管代码根目录（需为相对路径）"
    },
    "cloudfunctionRoot": {
      "type": "string",
      "description": "云函数代码根目录（需为相对路径）"
    },
    "cloudfunctionTemplateRoot": {
      "type": "string",
      "description": "云函数本地调试请求模板的根目录（需为相对路径）"
    },
    "compileType": {
      "type": "string",
      "description": "编译类型",
      "default": "miniprogram",
      "oneOf": [
        {
          "const": "miniprogram",
          "description": "当前为普通小程序项目"
        },
        {
          "const": "plugin",
          "description": "当前为小程序插件项目"
        }
      ]
    },
    "debugOptions": {
      "type": "object",
      "description": "调试配置选项",
      "properties": {
        "hidedInDevtools": {
          "type": "array",
          "description": "配置调试时于调试器 Sources 面板隐藏源代码的文件",
          "$ref": "#/definitions/array-of-match"
        }
      },
      "additionalProperties": false
    },
    "description": {
      "type": "string",
      "description": "项目描述"
    },
    "editorSetting": {
      "type": "object",
      "description": "指定自动生成的文件的 tabIndent 和 tabSize",
      "properties": {
        "tabIndent": {
          "type": "boolean",
          "description": "是否使用 tab 缩进"
        },
        "tabSize": {
          "type": "number",
          "description": "tab 大小",
          "minimum": 1
        }
      },
      "additionalProperties": false
    },
    "libVersion": {
      "type": "string",
      "description": "基础库版本",
      "oneOf": [
        {
          "pattern": "^[0-9]+.[0-9]+.[0-9]+$",
          "description": "版本号"
        },
        {
          "const": "latest",
          "description": "最新的非灰度中的基础库"
        },
        {
          "const": "trial",
          "description": "最新的基础库"
        },
        {
          "const": "widelyUsed",
          "description": "使用比例最高的基础库"
        }
      ]
    },
    "miniprogramRoot": {
      "type": "string",
      "description": "小程序源码的目录（需为相对路径）"
    },
    "packOptions": {
      "type": "object",
      "description": "打包配置选项",
      "properties": {
        "include": {
          "type": "array",
          "description": "配置打包时需要强制带上的文件或者文件夹",
          "$ref": "#/definitions/array-of-match"
        },
        "ignore": {
          "type": "array",
          "description": "配置打包时对符合指定规则的文件或文件夹进行忽略",
          "$ref": "#/definitions/array-of-match"
        }
      },
      "additionalProperties": false
    },
    "pluginRoot": {
      "type": "string",
      "description": "插件项目的目录（需为相对路径）"
    },
    "projectname": {
      "type": "string",
      "description": "项目名字"
    },
    "qcloudRoot": {
      "type": "string",
      "description": "腾讯云项目的目录（需为相对路径）"
    },
    "scripts": {
      "type": "object",
      "description": "自定义预处理",
      "properties": {
        "beforeCompile": {
          "type": "string",
          "description": "编译前预处理命令"
        },
        "beforePreview": {
          "type": "string",
          "description": "预览前预处理命令"
        },
        "beforeUpload": {
          "type": "string",
          "description": "上传前预处理命令"
        }
      },
      "additionalProperties": false
    },
    "setting": {
      "type": "object",
      "description": "项目设置",
      "properties": {
        "condition": {
          "type": "boolean",
          "description": "启用条件编译",
          "markdownDescription": "启用 [条件编译](https://dev.weixin.qq.com/docs/framework/dev/framework/operation/condition-compile.html)",
          "default": false
        },
        "es6": {
          "type": "boolean",
          "description": "是否启用 es6 转 es5",
          "default": false
        },
        "enhance": {
          "type": "boolean",
          "description": "是否打开增强编译",
          "default": false
        },
        "postcss": {
          "type": "boolean",
          "description": "上传代码时样式是否自动补全",
          "default": false
        },
        "minified": {
          "type": "boolean",
          "description": "上传代码时是否自动压缩脚本文件",
          "default": false
        },
        "minifyWXSS": {
          "type": "boolean",
          "description": "上传代码时是否自动压缩样式文件",
          "default": false
        },
        "minifyWXML": {
          "type": "boolean",
          "description": "上传代码时是否自动压缩 WXML 文件",
          "default": false
        },
        "swc": {
          "type": "boolean",
          "description": "开启 swc 编译模式",
          "default": false
        },
        "uglifyFileName": {
          "type": "boolean",
          "description": "上传时进行代码保护",
          "default": false
        },
        "ignoreUploadUnusedFiles": {
          "type": "boolean",
          "description": "上传时是否过滤无依赖文件",
          "default": false
        },
        "autoAudits": {
          "type": "boolean",
          "description": "是否自动运行体验评分",
          "default": false
        },
        "urlCheck": {
          "type": "boolean",
          "description": "是否检查安全域名和 TLS 版本",
          "default": false
        },
        "checkSiteMap": {
          "type": "boolean",
          "description": "是否检查 sitemap 配置"
        },
        "compileHotReLoad": {
          "type": "boolean",
          "description": "是否开启文件保存后自动热重载"
        },
        "preloadBackgroundData": {
          "type": "boolean",
          "description": "小程序加载时是否数据预拉取"
        },
        "lazyloadPlaceholderEnable": {
          "type": "boolean",
          "description": "是否启用懒注入占位组件调试"
        },
        "useStaticServer": {
          "type": "boolean",
          "description": "是否开启静态资源服务器，需要和staticServerOptions配合使用"
        },
        "bigPackageSizeSupport": {
          "type": "boolean",
          "description": "预览及真机调试的时主包、分包体积上限调整为4M（小程序）、8M（小游戏）"
        },
        "skylineRenderEnable": {
          "type": "boolean",
          "description": "是否开启 skyline 渲染调试",
          "default": true
        },
        "babelSetting": {
          "type": "object",
          "description": "增强编译下 Babel 的配置项",
          "properties": {
            "outputPath": {
              "type": "string",
              "description": "Babel 辅助函数的输出目录",
              "default": "@babel/runtime"
            },
            "ignore": {
              "type": "array",
              "description": "配置需要跳过 Babel 编译(包括代码压缩)处理的文件或目录",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "minifyWXMLSetting": {
          "type": "object",
          "patternProperties": {
            "^(global|.*\\.wxml)$": {
              "$ref": "#/definitions/minify-wxml-setting"
            }
          },
          "additionalProperties": false,
          "minProperties": 1
        },
        "useCompilerPlugins": {
          "description": "编译插件配置",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "enum": ["typescript", "less", "sass"]
              },
              "uniqueItems": true
            },
            {
              "type": "boolean",
              "const": false
            }
          ]
        },
        "disableUseStrict": {
          "type": "boolean",
          "description": "将 JS 编译成 ES5 时，是否禁用严格模式"
        },
        "uploadWithSourceMap": {
          "type": "boolean",
          "description": "上传时是否带上 sourcemap",
          "default": true
        },
        "localPlugins": {
          "type": "boolean",
          "description": "在小游戏插件项目中，是否启用 “以本地目录为插件资源来源” 特性"
        },
        "packNpmManually": {
          "type": "boolean",
          "description": "是否手动配置构建 npm 的路径"
        },
        "packNpmRelationList": {
          "type": "array",
          "description": "仅 packNpmManually 为 true 时生效，详细参考构建 npm 文档",
          "markdownDescription": "仅 `packNpmManually` 为 `true` 时生效，详细参考构建 npm 文档",
          "items": {
            "type": "object",
            "properties": {
              "packageJsonPath": {
                "type": "string",
                "description": "node_modules 源对应的 package.json",
                "minLength": 1
              },
              "miniprogramNpmDistDir": {
                "type": "string",
                "description": "node_modules 的构建结果目标位置",
                "minLength": 1
              }
            },
            "required": ["packageJsonPath", "miniprogramNpmDistDir"]
          }
        },
        "coverView": {
          "type": "boolean",
          "description": "是否使用工具渲染 CoverView"
        },
        "ignoreDevUnusedFiles": {
          "type": "boolean",
          "description": "预览、真机调试和本地模拟器等开发阶段是否过滤无依赖文件",
          "default": true
        },
        "ignoreCodeQuality": {
          "type": "boolean",
          "description": "预览、真机调试上传等开发阶段是否不执行代码质量检测",
          "default": false
        },
        "checkInvalidKey": {
          "type": "boolean",
          "description": "是否展示 JSON 文件校验错误信息"
        },
        "showShadowRootInWxmlPanel": {
          "type": "boolean",
          "description": "是否开启调试器 WXML 面板展示 shadow-root"
        },
        "useIsolateContext": {
          "type": "boolean",
          "description": "是否开启小程序独立域调试特性"
        },
        "useMultiFrameRuntime": {
          "type": "boolean",
          "description": "是否开启模拟器预先载入小程序的某些资源。此设定为 false 时会导致 useIsolateContext 失效"
        },
        "useApiHook": {
          "type": "boolean",
          "description": "是否启用 API Hook 功能"
        },
        "useApiHostProcess": {
          "type": "boolean",
          "description": "是否在额外的进程处理一些小程序 API"
        },
        "useLanDebug": {
          "type": "boolean",
          "description": "仅在小游戏有效，是否开启局域网调试服务器"
        },
        "enableEngineNative": {
          "type": "boolean",
          "description": "是否在游戏引擎项目中开启支持引用 node 原生模块的底层加速特性"
        },
        "showES6CompileOption": {
          "type": "boolean",
          "description": "是否在本地设置中展示传统的 ES6 转 ES5 开关（对应 es6），增强编译开关 （对应 enhance）"
        }
      },
      "additionalProperties": false
    },
    "skeletonConfig": {
      "type": "object",
      "description": "骨架屏相关设置",
      "properties": {
        "global": {
          "type": "object",
          "description": "全局骨架屏配置",
          "$ref": "#/definitions/skeleton"
        },
        "pages": {
          "type": "object",
          "description": "指向页面的骨架屏配置",
          "additionalProperties": false,
          "patternProperties": {
            "^pages/[a-zA-Z0-9-_/]+$": {
              "type": "object",
              "description": "页面骨架屏配置",
              "$ref": "#/definitions/skeleton"
            }
          }
        }
      },
      "additionalProperties": false
    },
    "staticServerOptions": {
      "type": "object",
      "description": "在微信开发者工具里开启一个本地静态资源服务器，用于托管项目静态资源，仅在小游戏项目中有效",
      "properties": {
        "servePath": {
          "type": "string",
          "description": "指向项目路径下的某个目录作为静态资源路径",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "watchOptions": {
      "type": "object",
      "description": "文件监听配置设置",
      "properties": {
        "ignore": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    }
  },
  "required": ["appid", "compileType", "projectname"]
}
