I have a "drupal/legacy-project" Drupal 9 project (it was packed inside bought custom drupal theme and later updated to latest drupal 9 version) and I need some custom edits in my root .htaccess file. When I run "composer update" all my custom edits in .htacess are gone and my site is immediately broken. Composer output:
Scaffolding files for drupal/core:
- Copy [web-root]/.htaccess from assets/scaffold/files/htaccess
I want my root .htaccess updated with a core updates since there might be some security updates in the future. But also I want to keep my custom lines in the .htaccess. So I tried to implement file-mapping option in my composer.json:
"file-mapping": {
"[web-root]/.htaccess": {
"prepend": "assets/my_htaccess_additions.txt"
}
}
But instead of prepending my custom lines from assets/my_htaccess_additions.txt file to root .htaccess I got no scaffolding at all and this text in my composer output:
Scaffolding files for drupal/core:
Skip [web-root]/.htaccess: overridden in drupal/legacy-project
Why is that and why composer mentions two projects (drupal/core and drupal/legacy-project) instead of one? Also I need to mention that this file-mapping setup works perfectly in my dev environment, but not in my prod environment
Thanks.
My system: ubuntu 18.04, php7.4, apache2. My composer.json contents:
{
"name": "drupal/legacy-project",
"description": "Project template for Drupal 9 projects with composer following drupal/drupal layout",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal",
"support": {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^1.9",
"drupal/admin_toolbar": "^3.1",
"drupal/better_exposed_filters": "^5.2",
"drupal/block_visibility_groups": "^1.4",
"drupal/color_field": "^2.5",
"drupal/colorbox": "^1.10",
"drupal/commerce": "^2.30",
"drupal/commerce_currency_resolver": "^1.60",
"drupal/commerce_shipping": "^2.4",
"drupal/commerce_stock": "^1.0",
"drupal/contact_block": "^1.6",
"drupal/core-composer-scaffold": "^9.4",
"drupal/core-project-message": "^9.4",
"drupal/core-recommended": "^9.4",
"drupal/core-vendor-hardening": "^9.4",
"drupal/ctools": "^4.0",
"drupal/entity_reference_facet_link": "^2.0",
"drupal/facets": "^2.0",
"drupal/facets_pretty_paths": "^1.2",
"drupal/field_timer": "^1.2",
"drupal/flag": "^4.0@beta",
"drupal/fontawesome": "^2.23",
"drupal/image_delta_formatter": "^1.1",
"drupal/inline_entity_form": "^1.0@RC",
"drupal/lang_dropdown": "^2.0",
"drupal/pathauto": "^1.10",
"drupal/redirect": "^1.7",
"drupal/search_api": "^1.24",
"drupal/simplenews": "^3.0@beta",
"drupal/token": "^1.10",
"drupal/video_embed_field": "^2.4",
"drupal/votingapi": "^3.0@beta",
"drupal/votingapi_widgets": "^1.0@alpha"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "stable",
"prefer-stable": true,
"config": {
"allow-plugins": {
"composer/installers": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
"drupal/core-vendor-hardening": true,
"dealerdirect/phpcodesniffer-composer-installer": true
},
"sort-packages": true
},
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "./"
},
"file-mapping": {
"[web-root]/.htaccess": {
"prepend": "assets/my_htaccess_additions.txt"
}
}
},
"installer-paths": {
"core": [
"type:drupal-core"
],
"libraries/{$name}": [
"type:drupal-library"
],
"modules/contrib/{$name}": [
"type:drupal-module"
],
"profiles/contrib/{$name}": [
"type:drupal-profile"
],
"themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/Commands/contrib/{$name}": [
"type:drupal-drush"
],
"modules/custom/{$name}": [
"type:drupal-custom-module"
],
"profiles/custom/{$name}": [
"type:drupal-custom-profile"
],
"themes/custom/{$name}": [
"type:drupal-custom-theme"
]
},
"drupal-core-project-message": {
"include-keys": [
"homepage",
"support"
],
"post-create-project-cmd-message": [
"<bg=blue;fg=white> </>",
"<bg=blue;fg=white> Congratulations, you’ve installed the Drupal codebase </>",
"<bg=blue;fg=white> from the drupal/legacy-project template! </>",
"<bg=blue;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",
" * Install the site: https://www.drupal.org/docs/8/install",
" * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
" * Get support: https://www.drupal.org/support",
" * Get involved with the Drupal community:",
" https://www.drupal.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
}
}
}
project_root/web
.