Skip to content

Commit

Permalink
chore: update webpack to use hash
Browse files Browse the repository at this point in the history
hash make consistence tranpiling

hash make consistence tranpiling

chore: remove dist folder from gitignore
  • Loading branch information
leangseu-edx committed Sep 5, 2023
1 parent 6679c6a commit c134ca6
Show file tree
Hide file tree
Showing 27 changed files with 46 additions and 96,529 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ private.py
# pyenv
.python-version

!openassessment/xblock/static/dist/
openassessment/xblock/static/dist/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ update-npm-requirements: ## update NPM requrements
cp ./node_modules/backgrid/lib/backgrid*.css $(STATIC_CSS)/lib/backgrid/

static: ## Webpack JavaScript and SASS source files
npm run dev && npm run build
npm run build

################
#Translations Handling
Expand Down
35 changes: 17 additions & 18 deletions openassessment/xblock/load_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,40 @@ class LoadStatic:
"""

_manifest = {}
_base_url = ''
_is_dev_server = False
_is_loaded = False

@staticmethod
def reload_manifest():
"""
Reload from manifest file
"""
root_url, base_url = '', '/static/dist/'
base_url_override = ''

if hasattr(settings, 'LMS_ROOT_URL'):
root_url = settings.LMS_ROOT_URL
else:
logger.error('LMS_ROOT_URL is undefined')

# comment this out while developing
if (LoadStatic._is_loaded):
return
try:
json_data = resource_string(__name__, 'static/dist/manifest.json').decode("utf8")
LoadStatic._manifest = json.loads(json_data)
base_url_override = LoadStatic._manifest.get('base_url', None)
LoadStatic._is_dev_server = LoadStatic._manifest.get('is_dev_server', False)
LoadStatic._is_loaded = True
except OSError:
logger.error('Cannot find static/dist/manifest.json')
finally:
if base_url_override and urlparse(base_url_override).scheme:
LoadStatic._base_url = base_url_override
else:
LoadStatic._base_url = urljoin(root_url, base_url)

@staticmethod
def get_url(key):
"""
get url from key
"""
if not LoadStatic._is_loaded:
LoadStatic.reload_manifest()
LoadStatic.reload_manifest()
url = LoadStatic._manifest[key] if key in LoadStatic._manifest else key
return urljoin(LoadStatic._base_url, url)
if LoadStatic._is_dev_server:
return url
return urljoin(settings.STATIC_URL, 'dist', url)

@staticmethod
def get_is_dev_server():
"""
get is_dev_server
"""
LoadStatic.reload_manifest()
return LoadStatic._is_dev_server

This file was deleted.

22 changes: 0 additions & 22 deletions openassessment/xblock/static/dist/manifest.json

This file was deleted.

This file was deleted.

Loading

0 comments on commit c134ca6

Please sign in to comment.