From debaf06c710d1e7db2acdff2aae63f3f894530cc Mon Sep 17 00:00:00 2001 From: Marcello Teodori Date: Mon, 21 Mar 2016 19:46:49 +0100 Subject: [PATCH] implements #340 Add support for CSS autoprefixer --- generators/app/templates/Gruntfile.js | 40 ++++++++++++++++++++++++-- generators/app/templates/_package.json | 2 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/generators/app/templates/Gruntfile.js b/generators/app/templates/Gruntfile.js index a70fa22..a981ca7 100644 --- a/generators/app/templates/Gruntfile.js +++ b/generators/app/templates/Gruntfile.js @@ -46,7 +46,7 @@ module.exports = function (grunt) { },<% } %><% if (sassBootstrap) { %> sass: { files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'], - tasks: ['sass:server'] + tasks: ['sass:server', 'postcss'] },<% } %> livereload: { options: { @@ -54,7 +54,7 @@ module.exports = function (grunt) { }, files: [ '<%%= yeoman.app %>/*.html', - '{.tmp,<%%= yeoman.app %>}/styles/{,*/}*.css', + '.tmp/styles/{,*/}*.css', '{.tmp,<%%= yeoman.app %>}/scripts/{,*/}*.js', '<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}', '<%%= yeoman.app %>/scripts/templates/*.{ejs,mustache,hbs}', @@ -79,6 +79,10 @@ module.exports = function (grunt) { ], tasks: ['jst'] }<% } %>, + styles: { + files: ['<%%= yeoman.app %>/styles/{,*/}*.css'], + tasks: ['copy:styles', 'postcss'] + }, test: { files: ['<%%= yeoman.app %>/scripts/{,*/}*.js', 'test/spec/**/*.js'], tasks: ['test:true'] @@ -132,6 +136,25 @@ module.exports = function (grunt) { path: 'http://localhost:<%%= connect.test.options.port %>' } }, + postcss: { + options: { + map: true, + processors: [ + // Add vendor prefixed styles + require('autoprefixer')({ + browsers: ['> 1%', 'last 2 versions', 'Firefox ESR'] + }) + ] + }, + dist: { + files: [{ + expand: true, + cwd: '.tmp/styles/', + src: '{,*/}*.css', + dest: '.tmp/styles/' + }] + } + }, clean: { dist: ['.tmp', '<%%= yeoman.dist %>/*'], server: '.tmp' @@ -329,6 +352,15 @@ module.exports = function (grunt) { } }, copy: { + styles: { + files: [{ + expand: true, + dot: true, + cwd: '<%%= yeoman.app %>/styles', + dest: '.tmp/styles/', + src: '{,*/}*.css' + }] + }, dist: { files: [{ expand: true, @@ -448,6 +480,7 @@ module.exports = function (grunt) { <% if (sassBootstrap) { -%> 'sass:server', <% } -%> + 'postcss', 'connect:test', 'open:test', 'watch' @@ -470,6 +503,7 @@ module.exports = function (grunt) { <% if (sassBootstrap) { -%> 'sass:server', <% } -%> + 'postcss', 'connect:livereload', 'open:server', 'watch' @@ -494,6 +528,7 @@ module.exports = function (grunt) { <% if (sassBootstrap) { -%> 'sass', <% } -%> + 'postcss', <% if(testFramework === 'mocha') { -%> 'connect:test', 'mocha' @@ -527,6 +562,7 @@ module.exports = function (grunt) { <% if (sassBootstrap) { -%> 'sass:dist', <% } -%> + 'postcss', 'useminPrepare', 'imagemin', 'htmlmin', diff --git a/generators/app/templates/_package.json b/generators/app/templates/_package.json index 106e881..2db0a2b 100644 --- a/generators/app/templates/_package.json +++ b/generators/app/templates/_package.json @@ -2,6 +2,7 @@ "private": true, "devDependencies": { "apache-server-configs": "^2.8.0", + "autoprefixer": "^6.3.4", "grunt": "^0.4.5", "grunt-contrib-copy": "^0.5.0", "grunt-contrib-concat": "^0.5.0", @@ -35,6 +36,7 @@ <% } -%> "grunt-rev": "^0.1.0", "grunt-open": "^0.2.3", + "grunt-postcss": "^0.8.0", <% if (sassBootstrap) { -%> "grunt-sass": "^1.0.0", <% } -%>