From c5ce45f5880792a44c5c036da7d24f07e3129c18 Mon Sep 17 00:00:00 2001 From: Konstantin Azizov Date: Tue, 4 Jul 2017 15:30:23 +0300 Subject: [PATCH] chore(build-system): replace Recess with PostCSS (#975) --- gruntfile.js | 60 ++++++++++++++++++++-------------------------------- package.json | 6 +++--- 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 3c24f3062..1c8df5bad 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -1,3 +1,6 @@ +var autoprefixer = require('autoprefixer'); +var cssnano = require('cssnano'); + module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-concat'); @@ -6,15 +9,14 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-html2js'); grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-if'); grunt.loadNpmTasks('grunt-filerev'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-usemin'); grunt.loadNpmTasks('grunt-replace'); grunt.loadNpmTasks('grunt-config'); + grunt.loadNpmTasks('grunt-postcss'); grunt.registerTask('default', ['eslint', 'build']); grunt.registerTask('build', [ @@ -23,7 +25,6 @@ module.exports = function (grunt) { 'if:linuxAmd64BinaryNotExist', 'html2js', 'useminPrepare:dev', - 'recess:build', 'concat', 'clean:tmpl', 'replace', @@ -37,10 +38,9 @@ module.exports = function (grunt) { 'clean:all', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy:assets', @@ -54,10 +54,9 @@ module.exports = function (grunt) { 'if:linux386BinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy:assets', @@ -71,10 +70,9 @@ module.exports = function (grunt) { 'if:linuxAmd64BinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy:assets', @@ -88,10 +86,9 @@ module.exports = function (grunt) { 'if:linuxArmBinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy', @@ -105,10 +102,9 @@ module.exports = function (grunt) { 'if:linuxArm64BinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy', @@ -122,10 +118,9 @@ module.exports = function (grunt) { 'if:linuxPpc64leBinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy', @@ -139,10 +134,9 @@ module.exports = function (grunt) { 'if:windowsAmd64BinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy', @@ -156,10 +150,9 @@ module.exports = function (grunt) { 'if:darwinAmd64BinaryNotExist', 'html2js', 'useminPrepare:release', - 'recess:build', 'concat', + 'postcss:build', 'clean:tmpl', - 'cssmin', 'replace', 'uglify', 'copy', @@ -304,6 +297,10 @@ module.exports = function (grunt) { } }, concat: { + css: { + src: ['<%= src.cssVendor %>', '<%= src.css %>'], + dest: '<%= distdir %>/css/<%= pkg.name %>.css' + }, dist: { options: { process: true @@ -358,27 +355,16 @@ module.exports = function (grunt) { dest: '<%= distdir %>/js/angular.js' } }, - recess: { // TODO: not maintained, unable to preserve license comments, switch out for something better. + postcss: { build: { - files: { - '<%= distdir %>/css/<%= pkg.name %>.css': ['<%= src.css %>'], - '<%= distdir %>/css/vendor.css': ['<%= src.cssVendor %>'] - }, options: { - compile: true, - noOverqualifying: false // TODO: Added because of .nav class, rename - } - }, - min: { - files: { - '<%= distdir %>/css/<%= pkg.name %>.css': ['<%= src.css %>'], - '<%= distdir %>/css/vendor.css': ['<%= src.cssVendor %>'] + processors: [ + autoprefixer({browsers: 'last 2 versions'}), // add vendor prefixes + cssnano() // minify the result + ] }, - options: { - compile: true, - compress: true, - noOverqualifying: false // TODO: Added because of .nav class, rename - } + src: '<%= distdir %>/css/<%= pkg.name %>.css', + dest: '<%= distdir %>/css/app.css' } }, watch: { diff --git a/package.json b/package.json index a1bfab28d..345e5f4a8 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,10 @@ "engines": { "node": ">= 0.8.4" }, - "dependencies": {}, "devDependencies": { + "autoprefixer": "^7.1.1", "bower": "^1.5.2", + "cssnano": "^3.10.0", "eslint": "^3.19.0", "grunt": "~0.4.0", "grunt-cli": "^1.2.0", @@ -32,7 +33,6 @@ "grunt-contrib-clean": "~0.4.0", "grunt-contrib-concat": "~0.1.3", "grunt-contrib-copy": "~0.4.0", - "grunt-contrib-cssmin": "^1.0.2", "grunt-contrib-jshint": "^1.1.0", "grunt-contrib-uglify": "^0.9.2", "grunt-contrib-watch": "~0.3.1", @@ -40,7 +40,7 @@ "grunt-html2js": "~0.1.0", "grunt-if": "^0.1.5", "grunt-karma": "~0.4.4", - "grunt-recess": "~0.3", + "grunt-postcss": "^0.8.0", "grunt-replace": "^1.0.1", "grunt-shell": "^1.1.2", "grunt-usemin": "^3.1.1",