Magento2: Cannot exclude Magento/blank at deploy static content

Created on 13 Jan 2018  路  11Comments  路  Source: magento/magento2

I have theme which is child of Magento/blank. I want to deploy static content for this theme but I don't need parent theme to deploy so i use --exclude-theme=Magento/blank option in command line

Preconditions


  1. Magento 2.2.2

Steps to reproduce

  1. Make theme which parent is Magento/blank
  2. Exclude theme from deploy use command: bin/magento setup:static-content:deploy --exclude-theme=Magento/blank

Expected result

  1. I have generated all themes except Magento/blank

Actual result

  1. Magento/blank is generated despite the exclusion

It was possible to exclude basic themes from generation in Magento 2.1

Clear Description Format is valid Ready for Work needs update Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

I had a quick look at this.

in file vendor/magento/module-deploy/Package/PackagePool.php

function getPackagesForDeployment(array $options)

This builds a list of themes that can be skipped based on what has been requested. It then intentionally checks if any of the themes to be skipped are parent themes of the themes being requested. If they are then they are not allowed to be skipped. So, it has been intentionally coded to operate as you report.

I attempted a quick mod to allow it to exclude deploying parent themes and the resultant theme that it deployed was not correct and was missing certain information that should have been inherited from the parent. It seems to be a bit more tightly bound than i thought.

I guess an alternative would be to copy/merge all files from blank/luma into your own theme, and then do not inherit from blank or luma. It should then just deploy only your theme, as it doesn't have any parents. The downside to this approach is that you would no longer receive layout updates/design changes deployed in the inbuilt themes at update time.

All 11 comments

For the record, I also am experiencing this on Magento 2.2.2.

Adding to that, if you inherit from luma, and deploy only your theme, excluding blank and luma on the command line, then both luma and blank are deployed in addition to your theme. Looks like it iterates through all parents right up to blank and deploys them.

@maqlec, thank you for your report.
We've acknowledged the issue and added to our backlog.

Any news on this one?

I had a quick look at this.

in file vendor/magento/module-deploy/Package/PackagePool.php

function getPackagesForDeployment(array $options)

This builds a list of themes that can be skipped based on what has been requested. It then intentionally checks if any of the themes to be skipped are parent themes of the themes being requested. If they are then they are not allowed to be skipped. So, it has been intentionally coded to operate as you report.

I attempted a quick mod to allow it to exclude deploying parent themes and the resultant theme that it deployed was not correct and was missing certain information that should have been inherited from the parent. It seems to be a bit more tightly bound than i thought.

I guess an alternative would be to copy/merge all files from blank/luma into your own theme, and then do not inherit from blank or luma. It should then just deploy only your theme, as it doesn't have any parents. The downside to this approach is that you would no longer receive layout updates/design changes deployed in the inbuilt themes at update time.

I agree with @gwharton
This is not a bug. If you exclude the parent theme from your theme, you have an uncomplete theme. If you don鈥檛 need the parent theme, just don鈥檛 declare it as parent. this reported behaviour is a feature which makes sure that the parent is deployed and the exclude parent is ignored to deploy a declared working theme.

@gwharton this alternative is not so good because when Im inheriting Magento/blank in my theme Im counting on updates from newest version of Magento without need to look every single file after update whats changed

@mautz-et-tong I think it is not right. Thats why we have a source themes and deploy step. Deploy command should decide from which theme should get the source file and which theme is the target one for this file basing on theme inheritance. From that reason I think I could exclude the base theme without "uncompletion" :) Note that each file from parent theme is copied to every child theme. This isnt symlinks for that files which are not changed (so it could be a nice solution)

Consider a situation:
You have a theme D inheriting from theme C and C inheriting from B and B inheriting from A. A is a Magento/blank and deployed size of that is 25MB. In that situation I want my store to have only D theme but Im forced to deploy C,B and A which costs 100MB and lasts 4x time longer.

Hi @engcom-Echo. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


Hi, @maqlec. Thank you for your report.
If your theme does not parent Magento/black car use for deploy:

$ bin/magento setup:static-content:deploy --theme <theme>

for this case, Magento/black theme does not deploy.

Theme Mageto/blank can't be excluded - it is a base theme.

Thanks for your collaboration!

The confusion probably happened because in Magento 2.1, the parent theme didn't get deployed, whereas from Magento 2.2 that changed for some reason (not exactly sure why, that might still be considered a bug though).
But basically from Magento 2.2 onwards you can't exclude parent themes from static content deployment.

Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.

Was this page helpful?
0 / 5 - 0 ratings