Skip to content

Commit

Permalink
insert setting WEBPACK_LOADER.PUBLIC_PATH_PREFIX before every asset url.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizpig64 committed Sep 9, 2023
1 parent 87b02a9 commit 48c4325
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions webpack_loader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# FIXME: Explore usage of fsnotify
'POLL_INTERVAL': 0.1,
'TIMEOUT': None,
'PUBLIC_PATH_PREFIX': '',
'IGNORE': [r'.+\.hot-update.js', r'.+\.map'],
'LOADER_CLASS': 'webpack_loader.loader.WebpackLoader',
'INTEGRITY': False,
Expand Down
8 changes: 6 additions & 2 deletions webpack_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ def map_chunk_files_to_url(self, chunks):
else:
yield {'name': chunk, 'url': url}

def prefix_url(self, url):
prefix = self.config.get('PUBLIC_PATH_PREFIX', '')
return prefix + url

def get_chunk_url(self, chunk_file):
public_path = chunk_file.get('publicPath')
if public_path:
return public_path
return self.prefix_url(public_path)

# Use os.path.normpath for Windows paths
relpath = os.path.normpath(
os.path.join(self.config['BUNDLE_DIR_NAME'], chunk_file['name'])
)
return staticfiles_storage.url(relpath)
return self.prefix_url(staticfiles_storage.url(relpath))

def get_bundle(self, bundle_name):
assets = self.get_assets()
Expand Down

0 comments on commit 48c4325

Please sign in to comment.