mirror of https://github.com/zulip/zulip.git
40 lines
1.2 KiB
Python
Executable File
40 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python
|
|
from __future__ import absolute_import
|
|
|
|
import optparse
|
|
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', 'tools/webpack.production.config.js'])
|
|
|
|
def run_watch(port):
|
|
# watch and rebuild on changes, serve file from memory via webpack-dev-server
|
|
subprocess.Popen(['tools/node', 'node_modules/.bin/webpack-dev-server'] +
|
|
['--config', 'tools/webpack.config.js', '--watch-poll', '--port', port])
|
|
|
|
parser = optparse.OptionParser()
|
|
parser.add_option('--watch',
|
|
action='store_true', dest='watch', default=False,
|
|
help='watch for changes to source files (for development)')
|
|
parser.add_option('--port',
|
|
action='store', dest='port',
|
|
default='9994', help='Set the port for the webpack server to run on')
|
|
(options, args) = parser.parse_args()
|
|
|
|
if options.watch:
|
|
run_watch(options.port)
|
|
else:
|
|
run()
|
|
|