Skip to content

Commit

Permalink
lazy load settings (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelniepel authored Mar 2, 2020
1 parent 65527bb commit 18df141
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions djangomix/templatetags/mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@

register = template.Library()

MANIFEST_DIRECTORY = getattr(settings, 'LARAVELMIX_MANIFEST_DIRECTORY','')
MANIFEST_DIRECTORY = getattr(settings, 'LARAVELMIX_MANIFEST_DIRECTORY', '')
PUBLIC_URL = getattr(settings, 'LARAVELMIX_PUBLIC_URL', settings.STATIC_URL)


@register.simple_tag
def mix(path, manifest_directory=MANIFEST_DIRECTORY):
os_sep = os.path.sep
def mix(path, manifest_directory=None):
if manifest_directory is None:
manifest_directory = MANIFEST_DIRECTORY

# laravel-mix generate / on the path in manifest.json
if path[0] != '/': # url separator
if path[0] != '/': # url separator
path = f'/{path}'


if os.path.exists(os.path.join(manifest_directory, 'hot')):
# taken from https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Mix.php
url = open(os.path.join(manifest_directory, 'hot')).read().strip()
Expand All @@ -25,11 +26,10 @@ def mix(path, manifest_directory=MANIFEST_DIRECTORY):
else:
return f'//localhost:8080{path}'

manifest_path = os.path.join(manifest_directory ,'mix-manifest.json')
manifest_path = os.path.join(manifest_directory, 'mix-manifest.json')

if not os.path.exists(manifest_path):
raise FileNotFoundError('Unable to locate manifest file: '
+ manifest_path)
raise FileNotFoundError('Unable to locate manifest file: ' + manifest_path)

with open(manifest_path, 'r') as f:
manifest = json.load(f)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages


version = '1.1.2'
version = '1.1.3'


# read the contents of your README file
Expand Down

0 comments on commit 18df141

Please sign in to comment.