[微信小程式開發]第4課 專案配置檔案
阿新 • • 發佈:2019-02-04
可以在專案根目錄使用 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": []
}
}
}
compileType 有效值
setting 中可以指定以下設定
scripts 中指定自定義預處理的命令
packOptions
packOptions 用以配置專案在打包過程中的選項。打包是預覽、上傳時對專案進行的必須步驟。
目前可以指定 packOptions.ignore 欄位,用以配置打包時對符合指定規則的檔案或資料夾進行忽略,以跳過打包的過程,這些檔案或資料夾將不會出現在預覽或上傳的結果內。
packOptions.ignore 為一物件陣列,物件元素型別如下:
其中,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": {}
}