Skip to content

Commit b7eddc3

Browse files
author
Andrey Fedoseev
committed
Add STATIC_PRECOMPILER_LIST_FILES setting
1 parent db2d749 commit b7eddc3

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Dev
1313
* ``SCSS_USE_COMPASS``
1414
* ``LESS_EXECUTABLE``
1515
- ``-C`` (``--no-cache``) flag is removed from SASS/SCSS compilers
16+
- Add ``STATIC_PRECOMPILER_LIST_FILES`` setting
1617

1718
0.8
1819
===

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ General settings
137137

138138
``STATIC_PRECOMPILER_DISABLE_AUTO_COMPILE``
139139
Disable automatic compilation from template tags or ``compile_static`` utility function. Files are compiled
140-
only with ``compilestatic`` command (see below).
140+
only with ``compilestatic`` command (see below). Default:: ``False``
141+
142+
``STATIC_PRECOMPILER_LIST_FILES``
143+
Whether or not ``static_precompiler.finders.StaticPrecompilerFinder`` will list compiled files when ``collectstatic``
144+
command is executed. Set to ``True`` if you want compiled files to be found by ``collectstatic``. Default:: ``False``.
145+
141146

142147
Compiler specific settings
143148
==========================

static_precompiler/finders.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.contrib.staticfiles.finders import BaseStorageFinder
22
from django.core.files.storage import FileSystemStorage
3-
from static_precompiler.settings import ROOT
3+
from static_precompiler.settings import ROOT, FINDER_LIST_FILES
44

55

66
class StaticPrecompilerFileStorage(FileSystemStorage):
@@ -17,12 +17,12 @@ def __init__(self, location=None, base_url=None):
1717

1818
class StaticPrecompilerFinder(BaseStorageFinder):
1919
"""
20-
A staticfiles finder that looks in STATIC_PRECOMPILER_ROOT
21-
for compiled files, to be used during development
22-
with staticfiles development file server or during
23-
deployment.
20+
A staticfiles finder that looks in STATIC_PRECOMPILER_ROOT for compiled files, to be used during development
21+
with staticfiles development file server or during deployment.
2422
"""
2523
storage = StaticPrecompilerFileStorage
2624

2725
def list(self, ignore_patterns):
26+
if FINDER_LIST_FILES:
27+
return super(StaticPrecompilerFinder, self).list(ignore_patterns)
2828
return []

static_precompiler/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@
6161
PREPEND_STATIC_URL = getattr(settings, 'STATIC_PRECOMPILER_PREPEND_STATIC_URL', False)
6262

6363
DISABLE_AUTO_COMPILE = getattr(settings, 'STATIC_PRECOMPILER_DISABLE_AUTO_COMPILE', False)
64+
FINDER_LIST_FILES = getattr(settings, 'STATIC_PRECOMPILER_FINDER_LIST_FILES', False)

test_project/test_project/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
STATIC_ROOT = os.path.join(BASE_DIR, 'test_project', 'static')
8686
STATIC_URL = '/static/'
8787

88+
STATICFILES_FINDERS = (
89+
"django.contrib.staticfiles.finders.FileSystemFinder",
90+
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
91+
"static_precompiler.finders.StaticPrecompilerFinder",
92+
)
8893

8994
LOGGING = {
9095
'version': 1,

0 commit comments

Comments
 (0)