webpack: Migrate api and katex js files to Webpack bundler.

This also injects the dev webpack sockets to katex, since that's part
of the main web app bundle.
This commit is contained in:
Mehanig 2017-05-24 15:18:27 -07:00 committed by Tim Abbott
parent 96db97d4f7
commit 8c0e500d6b
8 changed files with 17 additions and 18 deletions

View File

@ -18,6 +18,7 @@
"moment": "2.18.1", "moment": "2.18.1",
"moment-timezone": "0.5.12", "moment-timezone": "0.5.12",
"plotly.js": "1.19.2", "plotly.js": "1.19.2",
"script-loader": "0.7.0",
"source-map-loader": "0.2.1", "source-map-loader": "0.2.1",
"string.prototype.codepointat": "0.2.0", "string.prototype.codepointat": "0.2.0",
"ts-loader": "2.1.0", "ts-loader": "2.1.0",

View File

@ -4,10 +4,9 @@
{% block customhead %} {% block customhead %}
{{ super() }} {{ super() }}
{{ minified_js('api')|safe }} {{ render_bundle('api') }}
{% endblock %} {% endblock %}
{% block portico_content %} {% block portico_content %}
<h1 class="api-page-header">API endpoints documentation</h1> <h1 class="api-page-header">API endpoints documentation</h1>

View File

@ -28,7 +28,7 @@
</script> </script>
{% endblock %} {% endblock %}
{{ minified_js('common')|safe }} {{ minified_js('common')|safe }}
{{ minified_js('katex')|safe }} {{ render_bundle('katex') }}
{% block customhead %} {% block customhead %}
{% endblock %} {% endblock %}
</head> </head>

View File

@ -1,3 +1,5 @@
{ {
"translations": ["./static/js/translations.js"] "api": "./static/js/portico/api.js",
"katex": ["./node_modules/katex/dist/katex.min.js"],
"translations": "./static/js/translations.js"
} }

View File

@ -5,7 +5,6 @@ module.exports = {
context: path.resolve(__dirname, "../"), context: path.resolve(__dirname, "../"),
entry: assets, entry: assets,
module: { module: {
noParse: /(min)\.js/,
rules: [ rules: [
// Run the typescript compilier on .ts files before webpack // Run the typescript compilier on .ts files before webpack
{ {
@ -25,8 +24,14 @@ module.exports = {
test: /\.tsx?$/, test: /\.tsx?$/,
use: "source-map-loader", use: "source-map-loader",
}, },
// Uses script-loader on minified files so we don't change global variables in them.
// Also has the effect of making processing these files fast
{
test: /(min)\.js/,
use: [ 'script-loader' ],
},
], ],
}, },
output: { output: {
path: path.resolve(__dirname, '../static/webpack-bundles'), path: path.resolve(__dirname, '../static/webpack-bundles'),
filename: '[name].js', filename: '[name].js',

View File

@ -1,7 +1,9 @@
var config = require('./webpack.config.js'); var config = require('./webpack.config.js');
var BundleTracker = require('webpack-bundle-tracker'); var BundleTracker = require('webpack-bundle-tracker');
config.entry.translations.unshift('webpack-dev-server/client?sockjs-node'); // katex should be an array, to inject webpack dependencies in dev config
// better to be moved to common.js when common.js is added to assets
config.entry.katex.unshift('webpack-dev-server/client?/sockjs-node');
config.devtool = 'eval'; config.devtool = 'eval';
config.output.publicPath = '/webpack/'; config.output.publicPath = '/webpack/';
config.plugins.push(new BundleTracker({filename: 'static/webpack-bundles/webpack-stats-dev.json'})); config.plugins.push(new BundleTracker({filename: 'static/webpack-bundles/webpack-stats-dev.json'}));

View File

@ -1,2 +1,2 @@
ZULIP_VERSION = "1.6.0+git" ZULIP_VERSION = "1.6.0+git"
PROVISION_VERSION = '5.4' PROVISION_VERSION = '5.5'

View File

@ -841,10 +841,6 @@ JS_SPECS = {
], ],
'output_filename': 'min/zxcvbn.js' 'output_filename': 'min/zxcvbn.js'
}, },
'api': {
'source_filenames': ['js/portico/api.js'],
'output_filename': 'min/api.js'
},
'app_debug': { 'app_debug': {
'source_filenames': ['js/debug.js'], 'source_filenames': ['js/debug.js'],
'output_filename': 'min/app_debug.js' 'output_filename': 'min/app_debug.js'
@ -1023,12 +1019,6 @@ JS_SPECS = {
'sockjs': { 'sockjs': {
'source_filenames': ['third/sockjs/sockjs-0.3.4.js'], 'source_filenames': ['third/sockjs/sockjs-0.3.4.js'],
'output_filename': 'min/sockjs-0.3.4.min.js' 'output_filename': 'min/sockjs-0.3.4.min.js'
},
'katex': {
'source_filenames': [
'node_modules/katex/dist/katex.js',
],
'output_filename': 'min/katex.js'
} }
} }