目录

Project Configuration Using .json

You can configure the compilation behavior in the project configuration file, which makes it easier for you to use the compilation tool.

If the compilation behavior configured via the hvigor plugin parameters or command line parameters conflicts with the project configuration file, the configuration will be overwritten based on the parameter priority.

The parameter priority is as follows: user-defined parameters (hvigor plugin parameters or command line parameters) > personal configuration file (ascf.private.config.json) > configuration file (ascf.config.json) > ASCF system default parameters.

Dependency: ASCF Toolkit version 1.0.4 or later

  1. You can create the ascf.config.json and ascf.private.config.json files in the root directory to configure the project.

  2. You can configure common settings in the ascf.config.json file and personal settings in the ascf.private.config.json file. You can add the ascf.private.config.json file to the .gitignore file to avoid version management conflicts.

Attribute Type Description
packOptions Object Packages configuration options.
swc boolean

Whether to enable SWC for compilation. After this parameter is enabled, SWC is used to improve the compilation and build performance. By default, Babel is used.

Dependency: ASCF Toolkit version 1.0.9 or later

templateHoist boolean

Whether to use templateHoist. Set this parameter to true in the Taro-like framework (which uses the base.hxml template) to reduce repeated code and package size.

Dependency: ASCF Toolkit version 1.0.9 or later

disableSubpackages boolean

Whether to merge subpackages into the main package. Merging the subpackages into the main package during compilation in debug mode improves build performance.

Dependency: ASCF Toolkit version 1.0.9 or later

skipApiValidator boolean

Whether to skip the support verification of APIs and components. Skipping the support verification improves the compilation performance.

Dependency: ASCF Toolkit version 1.0.9 or later

logging string

Severity level of logs. The options are as follows:

- debug: debug messages

- info: information

- warn: warning

- error: error

Default value: info

Dependency: ASCF Toolkit version 1.0.9 or later

devtool string

Custom generation behavior of the source map. The value of type indicates the generation mode.

Default value: eval-cheap-source-map

Dependency: ASCF Toolkit version 1.0.9 or later

cache boolean | Object

Cache. You can set this parameter to false to disable the cache. The cache is enabled by default. For details, see the cache configuration of webpack.

Dependency: ASCF Toolkit version 1.0.9 or later

ascfDebugger string

ASCF debugger. If this parameter is set to brk, the first-line breakpoint is enabled.

Dependency: ASCF Toolkit version 1.0.9 or later

externalSwcHelpers boolean

Whether to enable error correction by external @swc/helpers. Set this parameter to false only when SWC is abnormal.

Dependency: ASCF Toolkit version 1.0.9 or later

compileMode string

Type of the project to be compiled and run. The options are ascf (default) and wx.

Dependency: ASCF Toolkit version 1.0.16 or later

emptyJsonpName Array

When there are multiple Taro packages and hot update is enabled, set this parameter to match output.jsonpFunction from the Webpack configuration of the corresponding Taro package.

Dependency: ASCF Toolkit version 1.0.16 or later

enableDevtools boolean

Whether to enable the ASCF Console debugging tool. You can determine whether to enable it in different environments based on the project requirements. This function is disabled by default.

Dependency: ASCF Toolkit version 1.0.17 or later

launchOptions Object

Startup parameters of the atomic service. This configuration is valid only for ascf.private.config.json.

Dependency: ASCF Toolkit version 1.0.17 or later

experimental Object

Experimental feature configuration.

Dependency: ASCF Toolkit version 1.0.9 or later

packOptions

You can use the packOptions.ignore field to skip the compilation and packaging of specified files or folders. These files or folders will not be displayed in the build products.

Attribute Type Description
value string Path or exclusion rule.
type string

Type to exclude. The options are as follows:

- folder: folder

- file: file

- suffix: suffix

- prefix: prefix

- regexp: regular expressions

- glob: glob rules

Example:

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

To ensure normal running, the packOptions.ignore field is ineffective for the pages configured in app.json and the components used.

launchOptions

Startup parameters of the atomic service.

Attribute Type Description
path string Path for starting the atomic service page (code package path).
query object Startup parameters, for example, {"name": "vendor"}.

experimental

You can configure experimental features to enable and use these features as required.

ASCF Toolkit may adjust experimental features and provide detailed descriptions of these updates in the changelog. Therefore, you are advised to pay attention to the changelog if you use experimental features.

Attribute Type Description
cacheBaseHxml boolean Whether to enable build cache. If templateHoist is set to true, the build cache using base.hxml is enabled by default. In abnormal cases, set this parameter to false to disable the cache.