diff --git a/src/meta/css.js b/src/meta/css.js index 91932d8233..c0c9cc71f0 100644 --- a/src/meta/css.js +++ b/src/meta/css.js @@ -206,7 +206,9 @@ CSS.buildBundle = function (target, fork, callback) { function (bundle, next) { var filename = target + '.css'; - fs.writeFile(path.join(__dirname, '../../build/public', filename), bundle.code, next); + fs.writeFile(path.join(__dirname, '../../build/public', filename), bundle.code, function (err) { + next(err, bundle.code); + }); }, ], callback); }; diff --git a/src/middleware/index.js b/src/middleware/index.js index 9f455f1a89..3328cee7b5 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -217,11 +217,14 @@ middleware.buildSkinAsset = function (req, res, next) { async.waterfall([ async.apply(plugins.prepareForBuild, ['client side styles']), async.apply(meta.css.buildBundle, target[0], true), - function (next) { - require('../meta/minifier').killAll(); - next(); - }, - ], next); + ], function (err, css) { + if (err) { + return next(); + } + + require('../meta/minifier').killAll(); + res.status(200).type('text/css').send(css); + }); } else { setImmediate(next); } diff --git a/src/routes/index.js b/src/routes/index.js index 57186e4e04..3c13e89a9c 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -159,11 +159,6 @@ function addCoreRoutes(app, router, middleware, callback) { statics.unshift({ route: '/assets/uploads', path: nconf.get('upload_path') }); } - // Skins - meta.css.supportedSkins.forEach(function (skin) { - app.use(relativePath + '/assets/client-' + skin + '.css', middleware.buildSkinAsset); - }); - statics.forEach(function (obj) { app.use(relativePath + obj.route, middleware.trimUploadTimestamps, express.static(obj.path, staticOptions)); }); @@ -171,6 +166,11 @@ function addCoreRoutes(app, router, middleware, callback) { res.redirect(relativePath + '/assets/uploads' + req.path + '?' + meta.config['cache-buster']); }); + // Skins + meta.css.supportedSkins.forEach(function (skin) { + app.use(relativePath + '/assets/client-' + skin + '.css', middleware.buildSkinAsset); + }); + // only warn once var warned = new Set();