Created
October 28, 2012 03:09
-
-
Save estebistec/3967289 to your computer and use it in GitHub Desktop.
Automatically detect apps with less folders to setup lessc include-path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_less_static_dirs(): | |
"""get static-directory paths for apps that have less files | |
Assumptions: | |
* You want any LESS files from apps in INSTALLED_APPS | |
* You don't have LESS files in any extra folders in STATIC_DIRS (maybe I should fix that... always thought static_dirs was dumb) | |
""" | |
app_modules = [import_module(app) for app in INSTALLED_APPS] | |
maybe_less_static_dirs = [ | |
# For Django apps, __file__ should always be the path to __init__.pyc | |
'{0}/static'.format(os.path.dirname(app_module.__file__)) | |
for app_module in app_modules | |
] | |
return [ | |
path for path in maybe_less_static_dirs | |
if os.path.isdir(os.path.join(path, 'less')) | |
] | |
PIPELINE_LESS_ARGUMENTS = '--include-path=' + ':'.join(get_less_static_dirs()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment