Skip to main content

Overwrite scaffold files in Drupal

Composer-scaffold is used by requiring drupal/core-composer-scaffold in the project, and providing configuration settings in the extra section of project's composer.json file.

1. Altering Scaffold Files (append/prepend some lines)

 "extra": {
    "drupal-scaffold": {
      "file-mapping": {
        "[web-root]/robots.txt": {
          "append": "assets/my-robots-additions.txt"
        }
      }
    }
  }

Create a file containing the lines that you want to add, and reference it within the 'extra' section.

 

2. Override a file entirely

"extra": {
    "drupal-scaffold": {
      "file-mapping": {
        "[web-root]/robots.txt": "assets/robots-override.txt"
      }
    }
  }

Create the file you want to use instead of core's version, and reference it within the 'extra' section.

 

3. Excluding Scaffold Files

"extra": {
    "drupal-scaffold": {
      "file-mapping": {
        "[web-root]/robots.txt": false
      }
    }
  }

If possible, it's better to use the append and prepend directives. Excluding a file means that project won't get any bug fixes or updates to files that are modified locally.

 

The full list of scaffold files can be found in core's composer.json file.