Skip to content

Commit

Permalink
Load node_modules via django-node-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Sep 3, 2024
1 parent 44a28db commit e08aef7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 36 deletions.
3 changes: 3 additions & 0 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1228,3 +1228,6 @@ watchdog[watchmedo]==3.0.0 \
--hash=sha256:c9d8c8ec7efb887333cf71e328e39cffbf771d8f8f95d308ea4125bf5f90ba64 \
--hash=sha256:d00e6be486affb5781468457b21a6cbe848c33ef43f9ea4a73b4882e5f188a44 \
--hash=sha256:d429c2430c93b7903914e4db9a966c7f2b068dd2ebdd2fa9b9ce094c7d459f33
django-node-assets==0.9.14 \
--hash=sha256:80cbe3d10521808309712b2aa5ef6d69799bbcafef844cf7f223d3c93f405768 \
--hash=sha256:d5b5c472136084d533268f52ab77897327863a102e25c81f484aae85eb806987
59 changes: 23 additions & 36 deletions src/olympia/lib/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def get_db_config(environ_var, atomic_requests=True):
'rangefilter',
'django_recaptcha',
'drf_yasg',
'django_node_assets',
# Django contrib apps
'django.contrib.admin',
'django.contrib.auth',
Expand Down Expand Up @@ -608,8 +609,7 @@ def get_db_config(environ_var, atomic_requests=True):
'css/devhub/buttons.less',
'css/devhub/in-app-config.less',
'css/devhub/static-theme.less',
# from @claviska/jquery-minicolors
'jquery.minicolors.css',
'@claviska/jquery-minicolors/jquery.minicolors.css',
'css/impala/devhub-api.less',
'css/devhub/dashboard.less',
),
Expand All @@ -626,13 +626,11 @@ def get_db_config(environ_var, atomic_requests=True):
'js': {
# JS files common to the entire site, apart from dev-landing.
'common': (
# from underscore
'underscore.js',
'underscore/underscore.js',
'js/zamboni/init.js',
'js/zamboni/capabilities.js',
'js/lib/format.js',
# from jquery.cookie
'jquery.cookie.js',
'jquery.cookie/jquery.cookie.js',
'js/zamboni/storage.js',
'js/common/keys.js',
'js/zamboni/helpers.js',
Expand All @@ -646,10 +644,8 @@ def get_db_config(environ_var, atomic_requests=True):
),
# Things to be loaded at the top of the page
'preload': (
# from jquery/dist/
'jquery.js',
# from jquery.browser/dist/
'jquery.browser.js',
'jquery/dist/jquery.js',
'jquery.browser/dist/jquery.browser.js',
'js/zamboni/analytics.js',
),
'zamboni/devhub': (
Expand All @@ -660,20 +656,17 @@ def get_db_config(environ_var, atomic_requests=True):
'js/common/upload-image.js',
'js/zamboni/devhub.js',
'js/zamboni/validator.js',
# from timeago
'jquery.timeago.js',

'timeago/jquery.timeago.js',
'js/zamboni/static_theme.js',
# from @claviska/jquery-minicolors
'jquery.minicolors.js',
# from jszip/dist
'jszip.js',
'@claviska/jquery-minicolors/jquery.minicolors.js',
'jszip/dist/jszip.js',
# jQuery UI for sortable
# from jquery-ui/ui
'data.js',
'scroll-parent.js',
'widget.js',
'mouse.js',
'sortable.js',
'jquery-ui/ui/data.js',
'jquery-ui/ui/scroll-parent.js',
'jquery-ui/ui/widget.js',
'jquery-ui/ui/widgets/mouse.js',
'jquery-ui/ui/widgets/sortable.js',
),
'devhub/new-landing/js': (
# Note that new-landing (devhub/index.html) doesn't include
Expand Down Expand Up @@ -1297,24 +1290,18 @@ def read_only_mode(env):
STATIC_ROOT = path('site-static')
STATIC_URL = '/static/'

NODE_MODULES_PATH = os.path.join('/', 'deps', 'node_modules')
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django_node_assets.finders.NodeModulesFinder',
)

def node_modules_path(*args):
return os.path.join(NODE_MODULES_PATH, *args)
NODE_MODULES_ROOT = os.path.join('/', 'deps', 'node_modules')
NODE_PACKAGE_JSON = os.path.join('/', 'deps', 'package.json')
NODE_PACKAGE_MANAGER_INSTALL_OPTIONS = ['--dry-run']

STATICFILES_DIRS = (
path('static'),
node_modules_path('less', 'dist'),
node_modules_path('jquery', 'dist'),
node_modules_path('jquery.browser', 'dist'),
node_modules_path('jquery.cookie'),
node_modules_path('@claviska', 'jquery-minicolors'),
node_modules_path('jszip', 'dist'),
node_modules_path('timeago', 'jquery.timeago'),
node_modules_path('underscore'),
node_modules_path('netmask', 'lib'),
node_modules_path('jquery-ui', 'ui'),

)

STATICFILES_STORAGE = 'olympia.lib.storage.ManifestStaticFilesStorageNotMaps'
Expand Down

0 comments on commit e08aef7

Please sign in to comment.