zulip/tools/webpack

41 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-10-26 17:11:44 +01:00
#!/usr/bin/env python
from __future__ import absolute_import
import argparse
2015-10-26 17:11:44 +01:00
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():
# type: () -> None
"""Builds for production, writing the output to disk"""
subprocess.check_call(['node', 'node_modules/.bin/webpack'] +
2016-04-06 17:09:55 +02:00
['--config', 'tools/webpack.production.config.js'])
2015-10-26 17:11:44 +01:00
def run_watch(port):
# type: (str) -> None
"""watches and rebuilds on changes, serving files from memory via webpack-dev-server"""
subprocess.Popen(['node', 'node_modules/.bin/webpack-dev-server'] +
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])
2015-10-26 17:11:44 +01:00
parser = argparse.ArgumentParser()
parser.add_argument('--watch',
action='store_true', dest='watch', default=False,
help='watch for changes to source files (for development)')
parser.add_argument('--port',
action='store', dest='port',
default='9994', help='set the port for the webpack server to run on')
args = parser.parse_args()
if args.watch:
run_watch(args.port)
else:
run()