Does anyone know if it's possible to restrict the setup:static-content:deploy to only deploy themes I actually use?
For instance i have a theme that inherits from Magento/blank and we have two languages, also we normally don't change the admin area.
So I only need
pub/static/frontend/MyScope/mytheme/en_GB and pub/static/frontend/MyScope/mytheme/en_US and
pub/static/adminhtml/* 
however I don't need all the others that are also being generated. I tried to at least uninstall luma but It didn't work and Magento/blank I can't remove because my theme inherits from it but it's not used in production.
Anyone got an idea?
- 
 Also see this: magento.stackexchange.com/questions/101131/…thdoan– thdoan2016年06月27日 03:40:12 +00:00Commented Jun 27, 2016 at 3:40
- 
 we ended up writing our own deployment script which is based on the original one (which only itereates through all themes and languages, so this was clean and easy)greenone83– greenone832016年06月27日 17:00:07 +00:00Commented Jun 27, 2016 at 17:00
- 
 please check below thread for answer. magento.stackexchange.com/questions/101131/…Abhishek Panchal– Abhishek Panchal2017年01月24日 21:27:50 +00:00Commented Jan 24, 2017 at 21:27
- 
 Now it can with help of this deploy module from Webmakkers: github.com/Webmakkers/magento-module-deployRinnert– Rinnert2023年11月20日 10:24:57 +00:00Commented Nov 20, 2023 at 10:24
3 Answers 3
According to this Magento 2 Github issue the functionality for this has not yet been implemented although they are in discussions about adding it.
As a workaround you can apparently delete and uninstall the luma theme (see instructions in my quote below) from the vendor directory and it will skip it. You may need to clear var/view_preprocessed, pub/static, and clear you caches for it to work though.
Comment from Alan Kent is on that github issue:
(If you want a short term hack, you can delete the Luma theme directory under 'vendor' so Magento does not see it any more. Make sure you run the CLI to uninstall the theme as well so it disappears from database etc. http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-theme-uninstall.html. Yes, we need a better solution, but it may remove some immediate pain.)
- 
 2
Now it possible.
You can use options --theme/--exclude-theme to restrict the list of themes to use.
Also, see more options to restrict items to deploy:
bin/magento setup:static-content:deploy --help
Usage:
 setup:static-content:deploy [-d|--dry-run] [-f|--force] [--no-javascript] [--no-css] [--no-less] [--no-images] [--no-fonts] [--no-html] [--no-misc] [--no-html-minify] [-t|--theme[="..."]] [--exclude-theme[="..."]] [-l|--language[="..."]] [--exclude-language[="..."]] [-a|--area[="..."]] [--exclude-area[="..."]] [-j|--jobs[="..."]] [--symlink-locale] [languages1] ... [languagesN]
Arguments:
 languages Space-separated list of ISO-636 language codes for which to output static view files.
Options:
 --dry-run (-d) If specified, then no files will be actually deployed.
 --force (-f) Deploy files in any mode.
 --no-javascript Do not deploy JavaScript files
 --no-css Do not deploy CSS files.
 --no-less Do not deploy LESS files.
 --no-images Do not deploy images.
 --no-fonts Do not deploy font files.
 --no-html Do not deploy HTML files.
 --no-misc Do not deploy other types of files (.md, .jbf, .csv, etc...).
 --no-html-minify Do not minify HTML files.
 --theme (-t) Generate static view files for only the specified themes. (default: ["all"]) (multiple values allowed)
 --exclude-theme Do not generate files for the specified themes. (default: ["none"]) (multiple values allowed)
 --language (-l) Generate files only for the specified languages. (default: ["all"]) (multiple values allowed)
 --exclude-language Do not generate files for the specified languages. (default: ["none"]) (multiple values allowed)
 --area (-a) Generate files only for the specified areas. (default: ["all"]) (multiple values allowed)
 --exclude-area Do not generate files for the specified areas. (default: ["none"]) (multiple values allowed)
 --jobs (-j) Enable parallel processing using the specified number of jobs. (default: 4)
 --symlink-locale Create symlinks for the files of those locales, which are passed for deployment, but have no customizations
 --help (-h) Display this help message
 --quiet (-q) Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V) Display this application version
 --ansi Force ANSI output
 --no-ansi Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question
To deploy selectively static content, use the following CLI command:
php bin/magento setup:static-content:deploy --theme=Vendor/themename 
Keep in mind, that in Developer mode you don't need to deploy static content at all.