From b72b101cc64471f4f09eba6d245fc2619f4d04ce Mon Sep 17 00:00:00 2001 From: Dimo Dimov Date: Wed, 12 Aug 2015 17:46:54 +0300 Subject: [PATCH] Add PostCss and Autoprefixer to LESS to CSS Grunt process task --- Gruntfile.js | 14 +++ build/grunt/tasks/less.js | 25 +++-- npm-shrinkwrap.json | 198 +++++++++++++++++++++++--------------- package.json | 3 + 4 files changed, 159 insertions(+), 81 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1495488b946..c2ee4433431 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,6 +6,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-debug-task'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-postcss'); grunt.loadTasks('build/grunt/tasks'); // support different test sets for public|private repo @@ -227,6 +228,19 @@ module.exports = function(grunt) { less: { options: { destDir: "<%= kendo.options.destDir %>", + autoprefixer: { + browsers: ([ + "Explorer >= 7", + "Chrome >= 21", + "Firefox ESR", + "Opera >= 15", + "Android >= 2.3", + "Safari >= 6.2.6", + "ExplorerMobile >= 10", + "iOS >= 6", + "BlackBerry >= 10" + ]).join(",") + } }, compile: { src: [ "styles/**/kendo*.less" ], diff --git a/build/grunt/tasks/less.js b/build/grunt/tasks/less.js index c2189a2f703..20b593baba9 100644 --- a/build/grunt/tasks/less.js +++ b/build/grunt/tasks/less.js @@ -1,11 +1,15 @@ var PATH = require("path"); var LESS = require("less"); var CSSMIN = require("cssmin").cssmin; +var postcss = require("postcss"); module.exports = function(grunt) { grunt.registerMultiTask("less", "Build CSS styles", function(){ var task = this; - var destDir = task.options().destDir; + var options = task.options(); + var destDir = options.destDir; + var autoprefixer = require("autoprefixer-core")(options.autoprefixer); + task.files.forEach(function(f){ f.src.forEach(function(f){ var base = PATH.dirname(f); @@ -14,15 +18,24 @@ module.exports = function(grunt) { filename : PATH.basename(f), syncImport: true }); - grunt.log.writeln("Compiling stylesheet: " + f); + grunt.log.writeln("Compiling LESS file: " + f); p.parse(grunt.file.read(f), function(err, tree){ try { var css = tree.toCSS(); - grunt.file.write(PATH.join(destDir, f.replace(/\.less$/, ".css")), css); - var cssmin = CSSMIN(css); - grunt.file.write(PATH.join(destDir, f.replace(/\.less$/, ".min.css")), cssmin); + postcss([ autoprefixer ]).process(css).then(function (result) { + result.warnings().forEach(function (warn) { + console.warn(warn.toString()); + }); + + var cssFile = f.replace(/\.less$/, ".css"); + grunt.log.writeln("Autoprefixing CSS file: " + cssFile); + + grunt.file.write(PATH.join(destDir, cssFile), result.css); + var cssmin = CSSMIN(result.css); + grunt.file.write(PATH.join(destDir, f.replace(/\.less$/, ".min.css")), cssmin); + }); } catch(ex) { - grunt.log.error("Can't LESS-compile " + f); + grunt.log.error("Can't process LESS file " + f); console.log(ex); } }); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 93f9a98a27b..da4bf1a36b3 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -4,101 +4,111 @@ "dependencies": { "jasmine-core": { "version": "2.3.4", - "from": "jasmine-core@*", + "from": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.3.4.tgz", "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.3.4.tgz" }, "karma-jasmine": { "version": "0.3.6", - "from": "karma-jasmine@*", + "from": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-0.3.6.tgz", "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-0.3.6.tgz" }, "karma-phantomjs-launcher": { "version": "0.2.1", - "from": "karma-phantomjs-launcher@*", + "from": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-0.2.1.tgz", "resolved": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-0.2.1.tgz", "dependencies": { "lodash": { "version": "3.10.1", - "from": "lodash@>=3.10.1 <4.0.0", + "from": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" } } }, "karma-requirejs": { "version": "0.2.2", - "from": "karma-requirejs@*" + "from": "karma-requirejs@0.2.2", + "resolved": "https://registry.npmjs.org/karma-requirejs/-/karma-requirejs-0.2.2.tgz" }, "karma-script-launcher": { "version": "0.1.0", - "from": "karma-script-launcher@*" + "from": "karma-script-launcher@0.1.0", + "resolved": "https://registry.npmjs.org/karma-script-launcher/-/karma-script-launcher-0.1.0.tgz" }, "phantomjs": { "version": "1.9.18", - "from": "phantomjs@>=1.9.0", + "from": "https://registry.npmjs.org/phantomjs/-/phantomjs-1.9.18.tgz", "resolved": "https://registry.npmjs.org/phantomjs/-/phantomjs-1.9.18.tgz", "dependencies": { "adm-zip": { "version": "0.4.4", - "from": "adm-zip@0.4.4", + "from": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.4.tgz", "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.4.tgz" }, "fs-extra": { "version": "0.23.1", - "from": "fs-extra@>=0.23.1 <0.24.0", + "from": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.23.1.tgz", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.23.1.tgz", "dependencies": { "graceful-fs": { "version": "4.1.2", - "from": "graceful-fs@>=4.1.2 <5.0.0", + "from": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.2.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.2.tgz" }, "jsonfile": { "version": "2.2.1", - "from": "jsonfile@>=2.1.0 <3.0.0", + "from": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.2.1.tgz", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.2.1.tgz" }, "path-is-absolute": { "version": "1.0.0", - "from": "path-is-absolute@>=1.0.0 <2.0.0" + "from": "path-is-absolute@1.0.0", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" }, "rimraf": { "version": "2.4.2", - "from": "rimraf@>=2.2.8 <3.0.0", + "from": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.2.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.2.tgz", "dependencies": { "glob": { "version": "5.0.14", - "from": "glob@>=5.0.14 <6.0.0", + "from": "glob@5.0.14", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.14.tgz", "dependencies": { "inflight": { "version": "1.0.4", - "from": "inflight@>=1.0.4 <2.0.0", + "from": "inflight@1.0.4", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", "dependencies": { "wrappy": { "version": "1.0.1", - "from": "wrappy@>=1.0.0 <2.0.0" + "from": "wrappy@1.0.1", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" } } }, "inherits": { "version": "2.0.1", - "from": "inherits@>=2.0.0 <3.0.0" + "from": "inherits@2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" }, "minimatch": { "version": "2.0.10", - "from": "minimatch@>=2.0.1 <3.0.0", + "from": "minimatch@2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", "dependencies": { "brace-expansion": { "version": "1.1.0", - "from": "brace-expansion@>=1.0.0 <2.0.0", + "from": "brace-expansion@1.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.0.tgz", "dependencies": { "balanced-match": { "version": "0.2.0", - "from": "balanced-match@>=0.2.0 <0.3.0" + "from": "balanced-match@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz" }, "concat-map": { "version": "0.0.1", - "from": "concat-map@0.0.1", + "from": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" } } @@ -107,11 +117,13 @@ }, "once": { "version": "1.3.2", - "from": "once@>=1.3.0 <2.0.0", + "from": "once@1.3.2", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.2.tgz", "dependencies": { "wrappy": { "version": "1.0.1", - "from": "wrappy@>=1.0.0 <2.0.0" + "from": "wrappy@1.0.1", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" } } } @@ -123,126 +135,140 @@ }, "kew": { "version": "0.4.0", - "from": "kew@0.4.0", + "from": "https://registry.npmjs.org/kew/-/kew-0.4.0.tgz", "resolved": "https://registry.npmjs.org/kew/-/kew-0.4.0.tgz" }, "npmconf": { "version": "2.1.1", - "from": "npmconf@2.1.1", + "from": "https://registry.npmjs.org/npmconf/-/npmconf-2.1.1.tgz", "resolved": "https://registry.npmjs.org/npmconf/-/npmconf-2.1.1.tgz", "dependencies": { "config-chain": { "version": "1.1.9", - "from": "config-chain@>=1.1.8 <1.2.0", + "from": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.9.tgz", "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.9.tgz", "dependencies": { "proto-list": { "version": "1.2.4", - "from": "proto-list@>=1.2.1 <1.3.0", + "from": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz" } } }, "inherits": { "version": "2.0.1", - "from": "inherits@>=2.0.0 <2.1.0" + "from": "inherits@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" }, "ini": { "version": "1.3.4", - "from": "ini@>=1.2.0 <2.0.0" + "from": "ini@1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz" }, "mkdirp": { "version": "0.5.1", - "from": "mkdirp@>=0.5.0 <0.6.0", + "from": "mkdirp@0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "dependencies": { "minimist": { "version": "0.0.8", - "from": "minimist@0.0.8", + "from": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" } } }, "nopt": { "version": "3.0.3", - "from": "nopt@>=3.0.1 <3.1.0", + "from": "https://registry.npmjs.org/nopt/-/nopt-3.0.3.tgz", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.3.tgz", "dependencies": { "abbrev": { "version": "1.0.7", - "from": "abbrev@>=1.0.0 <2.0.0", + "from": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz" } } }, "once": { "version": "1.3.2", - "from": "once@>=1.3.0 <1.4.0", + "from": "once@1.3.2", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.2.tgz", "dependencies": { "wrappy": { "version": "1.0.1", - "from": "wrappy@>=1.0.0 <2.0.0" + "from": "wrappy@1.0.1", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" } } }, "osenv": { "version": "0.1.3", - "from": "osenv@>=0.1.0 <0.2.0", + "from": "osenv@0.1.3", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz", "dependencies": { "os-homedir": { "version": "1.0.1", - "from": "os-homedir@>=1.0.0 <2.0.0" + "from": "os-homedir@1.0.1", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz" }, "os-tmpdir": { "version": "1.0.1", - "from": "os-tmpdir@>=1.0.0 <2.0.0" + "from": "os-tmpdir@1.0.1", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz" } } }, "semver": { "version": "4.3.6", - "from": "semver@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0||>=4.0.0 <5.0.0" + "from": "semver@4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz" }, "uid-number": { "version": "0.0.5", - "from": "uid-number@0.0.5", + "from": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.5.tgz", "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.5.tgz" } } }, "progress": { "version": "1.1.8", - "from": "progress@1.1.8", + "from": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz" }, "request": { "version": "2.42.0", - "from": "request@2.42.0", + "from": "https://registry.npmjs.org/request/-/request-2.42.0.tgz", "resolved": "https://registry.npmjs.org/request/-/request-2.42.0.tgz", "dependencies": { "bl": { "version": "0.9.4", - "from": "bl@>=0.9.0 <0.10.0", + "from": "bl@0.9.4", + "resolved": "https://registry.npmjs.org/bl/-/bl-0.9.4.tgz", "dependencies": { "readable-stream": { "version": "1.0.33", - "from": "readable-stream@>=1.0.26 <1.1.0", + "from": "readable-stream@1.0.33", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz", "dependencies": { "core-util-is": { "version": "1.0.1", - "from": "core-util-is@>=1.0.0 <1.1.0" + "from": "core-util-is@1.0.1", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" }, "isarray": { "version": "0.0.1", - "from": "isarray@0.0.1", + "from": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, "string_decoder": { "version": "0.10.31", - "from": "string_decoder@>=0.10.0 <0.11.0" + "from": "string_decoder@0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" }, "inherits": { "version": "2.0.1", - "from": "inherits@>=2.0.0 <3.0.0" + "from": "inherits@2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" } } } @@ -250,126 +276,148 @@ }, "caseless": { "version": "0.6.0", - "from": "caseless@>=0.6.0 <0.7.0" + "from": "caseless@0.6.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.6.0.tgz" }, "forever-agent": { "version": "0.5.2", - "from": "forever-agent@>=0.5.0 <0.6.0" + "from": "forever-agent@0.5.2", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz" }, "qs": { "version": "1.2.2", - "from": "qs@>=1.2.0 <1.3.0", + "from": "https://registry.npmjs.org/qs/-/qs-1.2.2.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-1.2.2.tgz" }, "json-stringify-safe": { "version": "5.0.1", - "from": "json-stringify-safe@>=5.0.0 <5.1.0" + "from": "json-stringify-safe@5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" }, "mime-types": { "version": "1.0.2", - "from": "mime-types@>=1.0.1 <1.1.0" + "from": "mime-types@1.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-1.0.2.tgz" }, "node-uuid": { "version": "1.4.3", - "from": "node-uuid@>=1.4.0 <1.5.0" + "from": "node-uuid@1.4.3", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" }, "tunnel-agent": { "version": "0.4.1", - "from": "tunnel-agent@>=0.4.0 <0.5.0" + "from": "tunnel-agent@0.4.1", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.1.tgz" }, "tough-cookie": { "version": "2.0.0", - "from": "tough-cookie@>=0.12.0" + "from": "tough-cookie@2.0.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.0.0.tgz" }, "form-data": { "version": "0.1.4", - "from": "form-data@>=0.1.0 <0.2.0", + "from": "form-data@0.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-0.1.4.tgz", "dependencies": { "combined-stream": { "version": "0.0.7", - "from": "combined-stream@>=0.0.4 <0.1.0", + "from": "combined-stream@0.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", "dependencies": { "delayed-stream": { "version": "0.0.5", - "from": "delayed-stream@0.0.5", + "from": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" } } }, "mime": { "version": "1.2.11", - "from": "mime@>=1.2.11 <1.3.0" + "from": "mime@1.2.11", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz" }, "async": { "version": "0.9.2", - "from": "async@>=0.9.0 <0.10.0" + "from": "async@0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz" } } }, "http-signature": { "version": "0.10.1", - "from": "http-signature@>=0.10.0 <0.11.0", + "from": "http-signature@0.10.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.1.tgz", "dependencies": { "assert-plus": { "version": "0.1.5", - "from": "assert-plus@>=0.1.5 <0.2.0" + "from": "assert-plus@0.1.5", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz" }, "asn1": { "version": "0.1.11", - "from": "asn1@0.1.11", + "from": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz" }, "ctype": { "version": "0.5.3", - "from": "ctype@0.5.3", + "from": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz", "resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz" } } }, "oauth-sign": { "version": "0.4.0", - "from": "oauth-sign@>=0.4.0 <0.5.0" + "from": "oauth-sign@0.4.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.4.0.tgz" }, "hawk": { "version": "1.1.1", "from": "hawk@1.1.1", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-1.1.1.tgz", "dependencies": { "hoek": { "version": "0.9.1", - "from": "hoek@>=0.9.0 <0.10.0" + "from": "hoek@0.9.1", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz" }, "boom": { "version": "0.4.2", - "from": "boom@>=0.4.0 <0.5.0" + "from": "boom@0.4.2", + "resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz" }, "cryptiles": { "version": "0.2.2", - "from": "cryptiles@>=0.2.0 <0.3.0" + "from": "cryptiles@0.2.2", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz" }, "sntp": { "version": "0.2.4", - "from": "sntp@>=0.2.0 <0.3.0" + "from": "sntp@0.2.4", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz" } } }, "aws-sign2": { "version": "0.5.0", - "from": "aws-sign2@>=0.5.0 <0.6.0" + "from": "aws-sign2@0.5.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz" }, "stringstream": { "version": "0.0.4", - "from": "stringstream@>=0.0.4 <0.1.0" + "from": "stringstream@0.0.4", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.4.tgz" } } }, "request-progress": { "version": "0.3.1", - "from": "request-progress@0.3.1", + "from": "https://registry.npmjs.org/request-progress/-/request-progress-0.3.1.tgz", "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-0.3.1.tgz", "dependencies": { "throttleit": { "version": "0.0.2", - "from": "throttleit@>=0.0.2 <0.1.0" + "from": "throttleit@0.0.2", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz" } } }, @@ -382,7 +430,7 @@ }, "requirejs": { "version": "2.1.20", - "from": "requirejs@>=2.1.0 <2.2.0", + "from": "https://registry.npmjs.org/requirejs/-/requirejs-2.1.20.tgz", "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.1.20.tgz" } } diff --git a/package.json b/package.json index 1f5ffeb10ce..f61301e7ad1 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,9 @@ "faye-websocket": "0.4.4", "less": "1.7.5", + "postcss": "^4.1.16", + "grunt-postcss": "^0.5.5", + "autoprefixer-core": "^5.2.1", "jshint": "1.1.0", "grunt": "~0.4.2",