mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-26 23:25:22 +02:00
Merge remote-tracking branch 'origin/master' into require.js
Conflicts: src/meta.js
This commit is contained in:
@@ -323,7 +323,8 @@ var fs = require('fs'),
|
||||
minifier.on('message', function(payload) {
|
||||
if (payload.action !== 'error') {
|
||||
winston.info('[meta/js] Compilation complete');
|
||||
Meta.js.cache = payload.data;
|
||||
Meta.js.cache = payload.data.js;
|
||||
Meta.js.map = payload.data.map;
|
||||
minifier.kill();
|
||||
} else {
|
||||
winston.error('[meta/js] Could not compile client-side scripts!');
|
||||
@@ -336,7 +337,8 @@ var fs = require('fs'),
|
||||
Meta.js.loadRJS(function() {
|
||||
Meta.js.prepare(function() {
|
||||
minifier.send({
|
||||
action: minify ? 'js.minify' : 'js.concatenate',
|
||||
action: 'js',
|
||||
minify: minify,
|
||||
scripts: Meta.js.scripts
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,18 +11,47 @@ var path = require('path'),
|
||||
|
||||
|
||||
function sendMinifiedJS(req, res, next) {
|
||||
if (!minificationEnabled) {
|
||||
res.set('X-SourceMap', '/nodebb.min.js.map');
|
||||
}
|
||||
|
||||
return res.type('text/javascript').send(meta.js.cache);
|
||||
}
|
||||
|
||||
function sendSourceMap(req, res) {
|
||||
return res.type('application/json').send(meta.js.map);
|
||||
}
|
||||
|
||||
function sendStylesheet(req, res, next) {
|
||||
res.type('text/css').send(200, meta.css.cache);
|
||||
}
|
||||
|
||||
module.exports = function(app, middleware, controllers) {
|
||||
minificationEnabled = app.enabled('minification');
|
||||
function setupPluginSourceMapping(app) {
|
||||
/*
|
||||
These mappings are utilised by the source map file, as client-side
|
||||
scripts defined in `scripts` in plugin.json are not normally
|
||||
served to the end-user. These mappings are only accessible via
|
||||
development mode (`./nodebb dev`)
|
||||
*/
|
||||
var routes = plugins.clientScripts,
|
||||
mapping;
|
||||
|
||||
routes.forEach(function(route) {
|
||||
mapping = '/' + route.split('/').slice(7).join('/');
|
||||
app.get(mapping, function(req, res) {
|
||||
res.type('text/javascript').sendfile(route);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function(app, middleware, controllers) {
|
||||
app.get('/stylesheet.css', sendStylesheet);
|
||||
app.get('/nodebb.min.js', sendMinifiedJS);
|
||||
app.get('/sitemap.xml', controllers.sitemap);
|
||||
app.get('/robots.txt', controllers.robots);
|
||||
|
||||
if (!minificationEnabled) {
|
||||
app.get('/nodebb.min.js.map', sendSourceMap);
|
||||
setupPluginSourceMapping(app);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user