diff --git a/package.json b/package.json index 630d20de16..a524513162 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ }, "dependencies": { "async": "~1.5.0", + "autoprefixer": "^6.2.3", "bcryptjs": "~2.3.0", "body-parser": "^1.9.0", "colors": "^1.1.0", @@ -59,6 +60,7 @@ "npm": "^2.1.4", "passport": "^0.3.0", "passport-local": "1.0.0", + "postcss": "^5.0.13", "prompt": "^0.2.14", "redis": "~2.4.2", "request": "^2.44.0", diff --git a/src/meta/css.js b/src/meta/css.js index 46b54ccb18..ce7c97dd7c 100644 --- a/src/meta/css.js +++ b/src/meta/css.js @@ -7,6 +7,8 @@ var winston = require('winston'), less = require('less'), crypto = require('crypto'), async = require('async'), + autoprefixer = require('autoprefixer'), + postcss = require('postcss'), plugins = require('../plugins'), emitter = require('../emitter'), @@ -185,16 +187,24 @@ module.exports = function(Meta) { return; } - Meta.css[destination] = lessOutput.css; + winston.verbose('[meta/css] Running PostCSS Plugins'); + postcss([ autoprefixer ]).process(lessOutput.css).then(function (result) { + result.warnings().forEach(function (warn) { + winston.verbose(warn.toString()); + }); - // Save the compiled CSS in public/ so things like nginx can serve it - if (nconf.get('isPrimary') === 'true') { - Meta.css.commitToFile(destination); - } + Meta.css[destination] = result.css; + + // Save the compiled CSS in public/ so things like nginx can serve it + if (nconf.get('isPrimary') === 'true') { + Meta.css.commitToFile(destination); + } + + if (typeof callback === 'function') { + callback(null, result.css); + } + }); - if (typeof callback === 'function') { - callback(null, lessOutput.css); - } }); }