[微信小程序开发]第4课 项目配置文件

可以在项目根目录使用 project.config.json 文件对项目进行配置。

{
    "description": "项目配置文件。",
    "packOptions": {
        "ignore": []
    },
    "setting": {
        "urlCheck": true,
        "es6": true,
        "postcss": true,
        "minified": true,
        "newFeature": true
    },
    "compileType": "miniprogram",
    "libVersion": "2.2.1",
    "appid": "wx68707f368e469bf8",
    "projectname": "bookshare",
    "isGameTourist": false,
    "condition": {
        "search": {
            "current": -1,
            "list": []
        },
        "conversation": {
            "current": -1,
            "list": []
        },
        "game": {
            "currentL": -1,
            "list": []
        },
        "miniprogram": {
            "current": -1,
            "list": []
        }
    }
}

image.png

  • compileType 有效值
    image.png

  • setting 中可以指定以下设置
    image.png

  • scripts 中指定自定义预处理的命令
    image.png

  • packOptions
    packOptions 用以配置项目在打包过程中的选项。打包是预览、上传时对项目进行的必须步骤。

目前可以指定 packOptions.ignore 字段,用以配置打包时对符合指定规则的文件或文件夹进行忽略,以跳过打包的过程,这些文件或文件夹将不会出现在预览或上传的结果内。
packOptions.ignore 为一对象数组,对象元素类型如下:
image.png

其中,type 可以取的值为 folder、file、suffix、prefix,分别对应文件夹、文件、后缀、前缀。
示例配置如下。

{
  "packOptions": {
    "ignore": [{
      "type": "file",
      "value": "test/test.js"
    }, {
      "type": "folder",
      "value": "test"
    }, {
      "type": "suffix",
      "value": ".webp"
    }, {
      "type": "prefix",
      "value": "test-"
    }]
  }
}

value 字段的值不支持通配符、正则表达式。若表示文件或文件夹路径,以小程序目录 (miniprogramRoot) 为根目录。

项目配置示例:

{
  "miniprogramRoot": "./src",
  "qcloudRoot": "./svr",
  "setting": {
    "postcss": true,
    "es6": true,
    "minified": true,
    "urlCheck": false
  },
  "packOptions": {}
}

猜你喜欢

转载自blog.csdn.net/tencupofkaiwater/article/details/81482576