mirror of
https://github.com/zulip/zulip.git
synced 2025-10-25 17:14:02 +00:00
Build and handle jsfiles using webpack instead of django-pipeline.
Also renames bundle.js to translations.js.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
static/js/bundle.js
|
|
||||||
static/js/blueslip.js
|
static/js/blueslip.js
|
||||||
puppet/zulip_ops/files/statsd/local.js
|
puppet/zulip_ops/files/statsd/local.js
|
||||||
|
static/webpack-bundles
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,6 +22,7 @@ static/generated/pygments_data.js
|
|||||||
static/generated/github-contributors.json
|
static/generated/github-contributors.json
|
||||||
static/locale/language_options.json
|
static/locale/language_options.json
|
||||||
static/third/emoji-data
|
static/third/emoji-data
|
||||||
|
static/webpack-bundles
|
||||||
/node_modules
|
/node_modules
|
||||||
/staticfiles.json
|
/staticfiles.json
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"string.prototype.codepointat": "0.2.0",
|
"string.prototype.codepointat": "0.2.0",
|
||||||
"underscore": "1.8.3",
|
"underscore": "1.8.3",
|
||||||
"webpack": "2.5.1",
|
"webpack": "2.5.1",
|
||||||
|
"webpack-bundle-tracker": "0.2.0",
|
||||||
"winchan": "0.2.0",
|
"winchan": "0.2.0",
|
||||||
"xdate": "0.8.0",
|
"xdate": "0.8.0",
|
||||||
"zxcvbn": "4.4.1"
|
"zxcvbn": "4.4.1"
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ uritemplate==3.0.0
|
|||||||
# Django extension for static asset pipeline
|
# Django extension for static asset pipeline
|
||||||
django-pipeline==1.6.12
|
django-pipeline==1.6.12
|
||||||
|
|
||||||
|
# Django extension for serving webpack modules
|
||||||
|
django-webpack-loader==0.5.0
|
||||||
|
|
||||||
# Needed for iOS push notifications
|
# Needed for iOS push notifications
|
||||||
git+https://github.com/sharmaeklavya2/PyAPNs.git@remove-simplejson#egg=apns==2.0.1
|
git+https://github.com/sharmaeklavya2/PyAPNs.git@remove-simplejson#egg=apns==2.0.1
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ var page_params = {{ page_params }};
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{{ minified_js('app')|safe }}
|
{{ minified_js('app')|safe }}
|
||||||
|
|
||||||
{% if not pipeline %}
|
{{ render_bundle('translations') }}
|
||||||
<script type="text/javascript" src="/webpack/bundle.js"></script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if debug %}
|
{% if debug %}
|
||||||
{{ minified_js('app_debug')|safe }}
|
{{ minified_js('app_debug')|safe }}
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ if prev_deploy:
|
|||||||
# Always use the newly compiled handlebars templates and webpack bundle.
|
# Always use the newly compiled handlebars templates and webpack bundle.
|
||||||
if prev_deploy:
|
if prev_deploy:
|
||||||
changed_files.add(os.path.join(STATIC_PATH, 'templates/compiled.js'))
|
changed_files.add(os.path.join(STATIC_PATH, 'templates/compiled.js'))
|
||||||
changed_files.add(os.path.join(STATIC_PATH, 'js/bundle.js'))
|
|
||||||
|
|
||||||
JS_SPECS = settings.JS_SPECS
|
JS_SPECS = settings.JS_SPECS
|
||||||
CLOSURE_BINARY = '/usr/bin/closure-compiler'
|
CLOSURE_BINARY = '/usr/bin/closure-compiler'
|
||||||
|
|||||||
@@ -196,6 +196,10 @@ if __name__ == "__main__":
|
|||||||
default=False,
|
default=False,
|
||||||
help=("Run the tests which failed the last time "
|
help=("Run the tests which failed the last time "
|
||||||
"test-backend was run. Implies --nonfatal-errors."))
|
"test-backend was run. Implies --nonfatal-errors."))
|
||||||
|
parser.add_option('--no-webpack', dest='no_webpack',
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Do not run webpack in tests.")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
zerver_test_dir = 'zerver/tests/'
|
zerver_test_dir = 'zerver/tests/'
|
||||||
@@ -301,6 +305,10 @@ if __name__ == "__main__":
|
|||||||
generate_fixtures_command.append('--force')
|
generate_fixtures_command.append('--force')
|
||||||
subprocess.call(generate_fixtures_command)
|
subprocess.call(generate_fixtures_command)
|
||||||
|
|
||||||
|
if not options.no_webpack:
|
||||||
|
print("Running Webpack with webpack.dev.config.js")
|
||||||
|
subprocess.check_call('tools/webpack')
|
||||||
|
|
||||||
if options.processes is None:
|
if options.processes is None:
|
||||||
options.processes = 4
|
options.processes = 4
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ def run():
|
|||||||
# type: () -> None
|
# type: () -> None
|
||||||
"""Builds for production, writing the output to disk"""
|
"""Builds for production, writing the output to disk"""
|
||||||
subprocess.check_call(['node', 'node_modules/.bin/webpack'] +
|
subprocess.check_call(['node', 'node_modules/.bin/webpack'] +
|
||||||
['--config', 'tools/webpack.production.config.js'])
|
['--config', 'tools/webpack.production.config.js', '-p'])
|
||||||
|
|
||||||
def run_watch(port):
|
def run_watch(port):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: [
|
context: path.resolve(__dirname, "../"),
|
||||||
'./static/js/src/main.js',
|
entry: {
|
||||||
],
|
translations: ['./static/js/translations.js'],
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, '../static/js'),
|
|
||||||
filename: 'bundle.js',
|
|
||||||
},
|
},
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, '../static/webpack-bundles'),
|
||||||
|
filename: '[name].js',
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
var config = require('./webpack.config.js');
|
var config = require('./webpack.config.js');
|
||||||
|
var BundleTracker = require('webpack-bundle-tracker');
|
||||||
|
|
||||||
config.entry.push('webpack-dev-server/client?http://0.0.0.0:9991/socket.io');
|
config.entry.translations.push('webpack-dev-server/client?http://0.0.0.0:9991/socket.io');
|
||||||
config.devtool = 'eval';
|
config.devtool = 'eval';
|
||||||
config.output.publicPath = 'http://0.0.0.0:9991/webpack/';
|
config.output.publicPath = 'http://0.0.0.0:9991/webpack/';
|
||||||
|
config.plugins.push(new BundleTracker({filename: 'static/webpack-bundles/webpack-stats-dev.json'}));
|
||||||
|
|
||||||
config.devServer = {
|
config.devServer = {
|
||||||
port: 9994,
|
port: 9994,
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
var config = require('./webpack.config.js');
|
var config = require('./webpack.config.js');
|
||||||
|
var BundleTracker = require('webpack-bundle-tracker');
|
||||||
|
|
||||||
|
config.devtool = 'source-map';
|
||||||
|
config.output.filename = '[name]-[hash].js';
|
||||||
|
config.plugins.push(new BundleTracker({filename: 'static/webpack-bundles/webpack-stats-production.json'}));
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ TEMPLATES = [
|
|||||||
'jinja2.ext.i18n',
|
'jinja2.ext.i18n',
|
||||||
'jinja2.ext.autoescape',
|
'jinja2.ext.autoescape',
|
||||||
'pipeline.jinja2.PipelineExtension',
|
'pipeline.jinja2.PipelineExtension',
|
||||||
|
'webpack_loader.contrib.jinja2ext.WebpackExtension',
|
||||||
],
|
],
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
'zerver.context_processors.zulip_default_context',
|
'zerver.context_processors.zulip_default_context',
|
||||||
@@ -360,6 +361,7 @@ INSTALLED_APPS = [
|
|||||||
'confirmation',
|
'confirmation',
|
||||||
'guardian',
|
'guardian',
|
||||||
'pipeline',
|
'pipeline',
|
||||||
|
'webpack_loader',
|
||||||
'zerver',
|
'zerver',
|
||||||
'social_django',
|
'social_django',
|
||||||
]
|
]
|
||||||
@@ -976,7 +978,6 @@ JS_SPECS = {
|
|||||||
'js/ui_init.js',
|
'js/ui_init.js',
|
||||||
'js/emoji_picker.js',
|
'js/emoji_picker.js',
|
||||||
'js/compose_ui.js',
|
'js/compose_ui.js',
|
||||||
# JS bundled by webpack is also included here if PIPELINE_ENABLED setting is true
|
|
||||||
],
|
],
|
||||||
'output_filename': 'min/app.js'
|
'output_filename': 'min/app.js'
|
||||||
},
|
},
|
||||||
@@ -1008,12 +1009,16 @@ JS_SPECS = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if PIPELINE_ENABLED:
|
|
||||||
# This is also done in test_settings.py, see comment there..
|
|
||||||
JS_SPECS['app']['source_filenames'].append('js/bundle.js')
|
|
||||||
|
|
||||||
app_srcs = JS_SPECS['app']['source_filenames']
|
app_srcs = JS_SPECS['app']['source_filenames']
|
||||||
|
|
||||||
|
WEBPACK_STATS_FILE = 'webpack-stats-dev.json' if DEVELOPMENT else 'webpack-stats-production.json'
|
||||||
|
WEBPACK_LOADER = {
|
||||||
|
'DEFAULT': {
|
||||||
|
'BUNDLE_DIR_NAME': 'webpack-bundles/',
|
||||||
|
'STATS_FILE': os.path.join(STATIC_ROOT, 'webpack-bundles', WEBPACK_STATS_FILE),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# LOGGING SETTINGS
|
# LOGGING SETTINGS
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ if USING_PGROONGA:
|
|||||||
DATABASES['default']
|
DATABASES['default']
|
||||||
DATABASES['default']['OPTIONS']['options'] = pg_options
|
DATABASES['default']['OPTIONS']['options'] = pg_options
|
||||||
|
|
||||||
# In theory this should just go in zproject/settings.py inside the `if
|
|
||||||
# PIPELINE_ENABLED` statement, but because zproject/settings.py is processed
|
|
||||||
# first, we have to add it here as a hack.
|
|
||||||
JS_SPECS['app']['source_filenames'].append('js/bundle.js')
|
|
||||||
|
|
||||||
if "TORNADO_SERVER" in os.environ:
|
if "TORNADO_SERVER" in os.environ:
|
||||||
# This covers the Casper test suite case
|
# This covers the Casper test suite case
|
||||||
TORNADO_SERVER = os.environ["TORNADO_SERVER"]
|
TORNADO_SERVER = os.environ["TORNADO_SERVER"]
|
||||||
@@ -99,6 +94,8 @@ CACHES['database'] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use production config from Webpack in tests
|
||||||
|
WEBPACK_LOADER['DEFAULT']['STATS_FILE'] = os.path.join(STATIC_ROOT, 'webpack-bundles', 'webpack-stats-production.json')
|
||||||
|
|
||||||
if CASPER_TESTS:
|
if CASPER_TESTS:
|
||||||
# Don't auto-restart Tornado server during casper tests
|
# Don't auto-restart Tornado server during casper tests
|
||||||
|
|||||||
Reference in New Issue
Block a user