# Project Configuration File

You can use the project.config.json file in the project root directory to configure the project.

Field Name Type Description
miniprogramRoot Path String Specifies the directory (a relative path) of the Mini Program source code
qcloudRoot Path String Specifies the directory (a relative path) of the Tencent Cloud project
pluginRoot Path String Specifies the directory (a relative path) of the plug-in project
compileType String Compilation type
setting Object Project settings
libVersion String Base library version
appid String Project's AppID, which is required only when a new project is created
projectname String Project name, which is required only when a new project is created
packOptions Object Package configuration options
debugOptions Object Debugging configuration options
scripts Object Custom preprocessing

Valid values of compileType

Name Description
miniprogram Indicates a Mini Program project
plugin Indicates a Mini Program plug-in project

The following fields can be specified in setting:

Field Type Description
es6 Boolean Specifies whether to enable ES6-to-ES5 conversion
postcss Boolean Specifies whether the style is automatically completed when the code is uploaded
minified Boolean Specifies whether the code is automatically compressed when it is uploaded
urlCheck Boolean Specifies whether to check the encrypted domain name and the TLS version
uglifyFileName Boolean Specifies whether to enable code protection
checkSiteMap Boolean Specifies whether to enable the SiteMap index prompt (it is true by default)
coverView Boolean Specifies whether to use DevTools to render CoverView
enhance Boolean Specifies whether to enable enhanced compilation
babelSetting Object Configuration item of Babel in enhanced compilation
uploadWithSourceMap Boolean Specifies whether to carry sourcemap when the code is uploaded (it is true by default)

The following fields can be specified in babelSetting:

Field Type Description
outputPath String The output directory of Babel's helper functions, which defaults to @babel/runtime
ignore Array<String> Specifies files or directories that need to skip Babel compilation (including code compression)

Note 1: In addition to a file path, you can also specify a directory. See the project configuration example below for details.

The following custom preprocessing commands can be specified in scripts

Name Description
beforeCompile Used before compilation
beforePreview Used before preview
beforeUpload Used before upload

# packOptions

packOptions is used to configure the options of project packaging. Packaging is a necessary step for previewing and uploading a project.

You can use the packOptions.ignore field to specify the filter rules. The files or folders that match the rules will be ignored when the project is packaged, and they will not appear in the preview or upload results.

packOptions.ignore is an array of objects with the following element types:

Field Type Description
value string Path1 or value
type string Type

Available values of type include folder, file, suffix, prefix, regexp2, and glob2, respectively corresponding to folders, files, suffixes, prefixes, regular expressions, and Glob rules. All values are case-insensitive.

Note 1: If the value of the value field indicates a file or folder path, the root directory is the Mini Program directory (miniprogramRoot).

Note 2: regexp and glob. is only supported as of Weixin DevTools 1.02.1809260.

Below is a configuration example.

{
  "packOptions": {
    "ignore": [{
      "type": "file",
      "value": "test/test.js"
    }, {
      "type": "folder",
      "value": "test"
    }, {
      "type": "suffix",
      "value": ".webp"
    }, {
      "type": "prefix",
      "value": "test-"
    }, {
      "type": "glob",
      "value": "test/**/*.js"
    }, {
      "type": "regexp",
      "value": "\\.jsx$"
    }]
  }
}

Note: Changes to any of the configuration items may not take effect until the project is reopened.

# debugOptions

debugOptions is used to configure the options during the debugging of the project code.

You can specify the debugOptions.hidedInDevtools field to configure files whose source code is hidden in the Sources panel of the debugger during debugging.

The configuration rule of hidedInDevtools is the same as that of packOptions.ignore.

When a js file complies with this rule, the content of its source code in the Sources panel of the debugger is hidden and shown as:

// xxx.js has been hided by project.config.json

Note: Once configured, the rule may not take effect until the project is closed and opened again.

Project configuration example:

{
  "miniprogramRoot": "./src",
  "qcloudRoot": "./svr",
  "setting": {
    "postcss": true,
    "es6": true,
    "minified": true,
    "urlCheck": false,
    "checkSiteMap": true,
    "enhance": true,
    "babelSetting": {
      "ignore": [
        "utils/something_not_to_process.js",
        "miniprogram_npm/*",
        "utils/already_handle/*"
      ]
    }
  },
  "packOptions": {
    "ignore": []
  },
  "debugOptions": {}
}