Skip to content

Instantly share code, notes, and snippets.

@ekohl
Created September 17, 2018 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekohl/4908170ed9166f6596054d14782eb0fe to your computer and use it in GitHub Desktop.
Save ekohl/4908170ed9166f6596054d14782eb0fe to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
"""
Automatic provides generator for webpack bundles
"""
import json
import sys
paths = [path.rstrip() for path in sys.stdin.readlines()]
for path in paths:
if path.endswith('webpack/manifest.json'):
with open(path) as fh:
manifest = json.load(fh)
for name, content in manifest['assetsByChunkName'].items():
if isinstance(content, basestring):
print 'foreman-webpack({}) = {}'.format(name, content))
else:
for chunk in content:
print 'foreman-webpack({}) = {}'.format(name, chunk))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment