Skip to content

Commit

Permalink
settings: Stop serving zxcvbn from node_modules/.
Browse files Browse the repository at this point in the history
Now that we have the minified_source_filenames feature, we don't need
to serve zxcvbn from node_modules/ directly to avoid re-minifying it.

Moving this this allows us to stop shipping the (duplicate)
node_modules directory in release tarballs, which will save many
megabytes of unnecessary increase in our release tarball size.
  • Loading branch information
timabbott committed Feb 7, 2017
1 parent e2ee195 commit babb6aa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ function _setup_page() {
if (page_params.password_auth_enabled !== false) {
// zxcvbn.js is pretty big, and is only needed on password
// change, so load it asynchronously.
$.getScript('/static/node_modules/zxcvbn/dist/zxcvbn.js', function () {
var zxcvbn_path = '/static/min/zxcvbn.js';
if (page_params.development_environment) {
// Usually the Django templates handle this path stuff
// for us, but in this case we need to hardcode it.
zxcvbn_path = '/static/node_modules/zxcvbn/dist/zxcvbn.js';
}
$.getScript(zxcvbn_path, function () {
$('#pw_strength .bar').removeClass("fade");
});
}
Expand Down
2 changes: 1 addition & 1 deletion templates/zerver/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{% block customhead %}
{{ super() }}
<script type="text/javascript" src="/static/node_modules/zxcvbn/dist/zxcvbn.js"></script>
{{ minified_js('zxcvbn')|safe }}
{% endblock %}

{% block portico_content %}
Expand Down
2 changes: 1 addition & 1 deletion templates/zerver/reset_confirm.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "zerver/portico_signup.html" %}
{% block customhead %}
{{ super() }}
<script type="text/javascript" src="/static/node_modules/zxcvbn/dist/zxcvbn.js"></script>
{{ minified_js('zxcvbn')|safe }}
{% endblock %}

{% block portico_content %}
Expand Down
7 changes: 7 additions & 0 deletions zproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,13 @@ def get_secret(key):
],
'output_filename': 'min/signup.js'
},
'zxcvbn': {
'source_filenames': [],
'minifed_source_filenames': [
'node_modules/zxcvbn/dist/zxcvbn.js',
],
'output_filename': 'min/zxcvbn.js'
},
'api': {
'source_filenames': ['js/portico/api.js'],
'output_filename': 'min/api.js'
Expand Down

0 comments on commit babb6aa

Please sign in to comment.