zulip/tools/webpack

31 lines
847 B
Python
Executable File

#!/usr/bin/env python
from __future__ import absolute_import
import os
import subprocess
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
from django.conf import settings
os.chdir(settings.DEPLOY_ROOT)
STATIC_PATH = 'static/'
def run():
# write the file to disk
subprocess.check_call(['tools/node', 'node_modules/.bin/webpack'] +
['--config', 'webpack.production.config.js'])
def run_watch():
# watch and rebuild on changes, serve file from memory via webpack-dev-server
subprocess.Popen(['tools/node', 'node_modules/.bin/webpack-dev-server'] +
['--config', 'webpack.config.js', '--watch-poll'])
if __name__ == '__main__':
if len(sys.argv) == 2 and sys.argv[1] == 'watch':
run_watch()
else:
run()