diff --git a/cms/envs/common.py b/cms/envs/common.py index 25ae0c42505973fa30ff1e6d48e791a2ed5b0055..f1d34953a14a7f0e2c9d067e872c6194922a69f4 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -277,13 +277,6 @@ XQUEUE_INTERFACE = { simplefilter('ignore') ################################# Middleware ################################### -# List of finder classes that know how to find static files in -# various locations. -STATICFILES_FINDERS = ( - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', - 'pipeline.finders.PipelineFinder', -) # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -460,9 +453,23 @@ MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' ##### EMBARGO ##### EMBARGO_SITE_REDIRECT_URL = None -############################### Pipeline ####################################### +############################### PIPELINE ####################################### + +# Process static files using RequireJS Optimizer STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage' +# List of finder classes that know how to find static files in various locations. +# Note: the pipeline finder is included to be able to discover optimized files +STATICFILES_FINDERS = [ + 'staticfiles.finders.FileSystemFinder', + 'staticfiles.finders.AppDirectoriesFinder', + 'pipeline.finders.PipelineFinder', +] + +# Don't use compression by default +PIPELINE_CSS_COMPRESSOR = None +PIPELINE_JS_COMPRESSOR = None + from openedx.core.lib.rooted_paths import rooted_glob PIPELINE_CSS = { @@ -550,7 +557,9 @@ PIPELINE_JS_COMPRESSOR = None STATICFILES_IGNORE_PATTERNS = ( "*.py", "*.pyc", - # it would be nice if we could do, for example, "**/*.scss", + "*.html", + + # It would be nice if we could do, for example, "**/*.scss", # but these strings get passed down to the `fnmatch` module, # which doesn't support that. :( # http://docs.python.org/2/library/fnmatch.html @@ -563,6 +572,10 @@ STATICFILES_IGNORE_PATTERNS = ( "coffee/*/*/*.coffee", "coffee/*/*/*/*.coffee", + # Ignore tests + "spec", + "spec_helpers", + # Symlinks used by js-test-tool "xmodule_js", "common_static", diff --git a/cms/envs/devstack.py b/cms/envs/devstack.py index 70e25475cab6e0f899baa7be81f210b8facc8e13..bd003236688fe401615145da57d5cbd0fc448178 100644 --- a/cms/envs/devstack.py +++ b/cms/envs/devstack.py @@ -33,8 +33,14 @@ FEATURES['PREVIEW_LMS_BASE'] = "preview." + LMS_BASE ########################### PIPELINE ################################# -# Skip RequireJS optimizer in development -STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' +# Skip packaging and optimization in development +STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' + +# Revert to the default set of finders as we don't want the production pipeline +STATICFILES_FINDERS = [ + 'staticfiles.finders.FileSystemFinder', + 'staticfiles.finders.AppDirectoriesFinder', +] ############################# ADVANCED COMPONENTS ############################# diff --git a/cms/envs/test_static_optimized.py b/cms/envs/test_static_optimized.py index 61cca130c1035da03f408af0bcbaa743060323fa..af030f16338875b6d9c82be644a4544515d46850 100644 --- a/cms/envs/test_static_optimized.py +++ b/cms/envs/test_static_optimized.py @@ -20,7 +20,17 @@ DATABASES = { }, } -######################### Static file overrides #################################### + +######################### PIPELINE #################################### + +# Use RequireJS optimized storage +STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage' + +# Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline +STATICFILES_FINDERS = [ + 'staticfiles.finders.FileSystemFinder', + 'staticfiles.finders.AppDirectoriesFinder', +] # Redirect to the test_root folder within the repo TEST_ROOT = REPO_ROOT / "test_root" @@ -33,4 +43,3 @@ STATIC_ROOT = (TEST_ROOT / "staticfiles" / "cms").abspath() # 1. Uglify is by far the slowest part of the build process # 2. Having full source code makes debugging tests easier for developers os.environ['REQUIRE_BUILD_PROFILE_OPTIMIZE'] = 'none' -PIPELINE_JS_COMPRESSOR = None diff --git a/lms/envs/common.py b/lms/envs/common.py index 73dfd5f03cb0f77ab7ae5eae4b70f2e2f88888a2..93b12020b2d8059c42a158e53dd1b06faa0225a7 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1115,13 +1115,6 @@ CREDIT_NOTIFICATION_CACHE_TIMEOUT = 5 * 60 * 60 simplefilter('ignore') ################################# Middleware ################################### -# List of finder classes that know how to find static files in -# various locations. -STATICFILES_FINDERS = ( - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', - 'pipeline.finders.PipelineFinder', -) # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( @@ -1209,10 +1202,32 @@ MIDDLEWARE_CLASSES = ( # Clickjacking protection can be enabled by setting this to 'DENY' X_FRAME_OPTIONS = 'ALLOW' -############################### Pipeline ####################################### +############################### PIPELINE ####################################### +# Process static files using RequireJS Optimizer STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage' +# List of finder classes that know how to find static files in various locations. +# Note: the pipeline finder is included to be able to discover optimized files +STATICFILES_FINDERS = [ + 'staticfiles.finders.FileSystemFinder', + 'staticfiles.finders.AppDirectoriesFinder', + 'pipeline.finders.PipelineFinder', +] + +# Don't use compression by default +PIPELINE_CSS_COMPRESSOR = None +PIPELINE_JS_COMPRESSOR = None + +# Setting that will only affect the edX version of django-pipeline until our changes are merged upstream +PIPELINE_COMPILE_INPLACE = True + +# Don't wrap JavaScript as there is code that depends upon updating the global namespace +PIPELINE_DISABLE_WRAPPER = True + +# Specify the UglifyJS binary to use +PIPELINE_UGLIFYJS_BINARY = 'node_modules/.bin/uglifyjs' + from openedx.core.lib.rooted_paths import rooted_glob courseware_js = ( @@ -1605,8 +1620,6 @@ PIPELINE_JS = { } } -PIPELINE_DISABLE_WRAPPER = True - # Compile all coffee files in course data directories if they are out of date. # TODO: Remove this once we move data into Mongo. This is only temporary while # course data directories are still in use. @@ -1627,25 +1640,32 @@ if os.path.isdir(DATA_DIR): os.system("coffee -c %s" % (js_dir / filename)) -PIPELINE_CSS_COMPRESSOR = None -PIPELINE_JS_COMPRESSOR = "pipeline.compressors.uglifyjs.UglifyJSCompressor" - STATICFILES_IGNORE_PATTERNS = ( - "sass/*", + "*.py", + "*.pyc", + "*.html", + + # It would be nice if we could do, for example, "**/*.scss", + # but these strings get passed down to the `fnmatch` module, + # which doesn't support that. :( + # http://docs.python.org/2/library/fnmatch.html + "sass/*.scss", + "sass/*/*.scss", + "sass/*/*/*.scss", + "sass/*/*/*/*.scss", "coffee/*.coffee", "coffee/*/*.coffee", "coffee/*/*/*.coffee", "coffee/*/*/*/*.coffee", + # Ignore tests + "spec", + "spec_helpers", + # Symlinks used by js-test-tool "xmodule_js", ) -PIPELINE_UGLIFYJS_BINARY = 'node_modules/.bin/uglifyjs' - -# Setting that will only affect the edX version of django-pipeline until our changes are merged upstream -PIPELINE_COMPILE_INPLACE = True - ################################# DJANGO-REQUIRE ############################### diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 3d90ef36a93b04dc30793bb8ef62769e6166341d..45563db818b928d421f0dde2b61a09a9b017b6eb 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -85,8 +85,17 @@ def should_show_debug_toolbar(_): ########################### PIPELINE ################################# -# # Skip RequireJS optimizer in development -STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' +# Skip packaging and optimization in development +STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' + +# Revert to the default set of finders as we don't want the production pipeline +STATICFILES_FINDERS = [ + 'staticfiles.finders.FileSystemFinder', + 'staticfiles.finders.AppDirectoriesFinder', +] + +# Disable JavaScript compression in development +PIPELINE_JS_COMPRESSOR = None # Whether to run django-require in debug mode. REQUIRE_DEBUG = DEBUG diff --git a/lms/envs/test_static_optimized.py b/lms/envs/test_static_optimized.py index 339189b56679b2f1701d47de8c3759a62f49f923..bd810b4a69cb83bf97f14d37a705e0c3425f8754 100644 --- a/lms/envs/test_static_optimized.py +++ b/lms/envs/test_static_optimized.py @@ -32,7 +32,16 @@ XQUEUE_INTERFACE = { } -######################### Static file overrides #################################### +######################### PIPELINE #################################### + +# Use RequireJS optimized storage +STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage' + +# Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline +STATICFILES_FINDERS = [ + 'staticfiles.finders.FileSystemFinder', + 'staticfiles.finders.AppDirectoriesFinder', +] # Redirect to the test_root folder within the repo TEST_ROOT = REPO_ROOT / "test_root" @@ -45,4 +54,3 @@ STATIC_ROOT = (TEST_ROOT / "staticfiles" / "lms").abspath() # 1. Uglify is by far the slowest part of the build process # 2. Having full source code makes debugging tests easier for developers os.environ['REQUIRE_BUILD_PROFILE_OPTIMIZE'] = 'none' -PIPELINE_JS_COMPRESSOR = None