Skip to content

Commit

Permalink
Merge pull request #71 from passy/autoprefixer
Browse files Browse the repository at this point in the history
Added support for autoprefixer
  • Loading branch information
addyosmani committed Jun 13, 2013
2 parents e8f77d2 + 498fcd9 commit 4fcdc36
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 15 deletions.
7 changes: 7 additions & 0 deletions app/index.js
Expand Up @@ -50,13 +50,20 @@ AppGenerator.prototype.askFor = function askFor() {
name: 'includeRequireJS',
message: 'Would you like to include RequireJS (for AMD support)?',
default: true
},
{
type: 'confirm',
name: 'autoprefixer',
message: 'Would you like to use autoprefixer for your CSS?',
default: false
}];

this.prompt(prompts, function (props) {
// manually deal with the response, get back and store the results.
// we change a bit this way of doing to automatically do this in the self.prompt() method.
this.compassBootstrap = props.compassBootstrap;
this.includeRequireJS = props.includeRequireJS;
this.autoprefixer = props.autoprefixer;

cb();
}.bind(this));
Expand Down
57 changes: 44 additions & 13 deletions app/templates/Gruntfile.js
Expand Up @@ -38,15 +38,20 @@ module.exports = function (grunt) {
},
compass: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server']
},
tasks: ['compass:server'<% if (autoprefixer) { %>, 'autoprefixer' <% } %>]
},<% if (autoprefixer) { %>
styles: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['copy:styles', 'autoprefixer']
},<% } %>
livereload: {
options: {
livereload: LIVERELOAD_PORT
},
files: [
'<%%= yeoman.app %>/*.html',
'{.tmp,<%%= yeoman.app %>}/styles/{,*/}*.css',
'<%%= yeoman.app %>/*.html',<% if (autoprefixer) { %>
'.tmp/styles/{,*/}*.css',<% } else { %>
'{.tmp,<%%= yeoman.app %>}/styles/{,*/}*.css',<% } %>
'{.tmp,<%%= yeoman.app %>}/scripts/{,*/}*.js',
'<%%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
Expand Down Expand Up @@ -173,7 +178,20 @@ module.exports = function (grunt) {
debugInfo: true
}
}
},
},<% if (autoprefixer) { %>
autoprefixer: {
options: {
browsers: ['last 1 version']
},
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},<% } %>
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
Expand Down Expand Up @@ -302,20 +320,30 @@ module.exports = function (grunt) {
'generated/*'
]
}]
}
}<% if (autoprefixer) { %>,
styles: {
expand: true,
dot: true,
cwd: '<%%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
}<% } %>
},
concurrent: {
server: [
'coffee:dist',
'compass:server'
'copy:styles'<% if (autoprefixer) { %>,
'autoprefixer'<% } %>
],
test: [
'coffee',
'compass'
'copy:styles'<% if (autoprefixer) { %>,
'autoprefixer'<% } %>
],
dist: [
'coffee',
'compass:dist',
'compass',<% if (autoprefixer) { %>
'copy:styles',<% } %>
'imagemin',
'svgmin',
'htmlmin'
Expand All @@ -338,7 +366,8 @@ module.exports = function (grunt) {

grunt.task.run([
'clean:server',
'concurrent:server',
'concurrent:server',<% if (autoprefixer) { %>
'autoprefixer',<% } %>
'connect:livereload',
'open',
'watch'
Expand All @@ -347,7 +376,8 @@ module.exports = function (grunt) {

grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'concurrent:test',<% if (autoprefixer) { %>
'autoprefixer',<% } %>
'connect:test',<% if (testFramework === 'mocha') { %>
'mocha'<% } else if (testFramework === 'jasmine') { %>
'jasmine'<% } %>
Expand All @@ -356,12 +386,13 @@ module.exports = function (grunt) {
grunt.registerTask('build', [
'clean:dist',
'useminPrepare',
'concurrent:dist',<% if (includeRequireJS) { %>
'concurrent:dist',<% if (autoprefixer) { %>
'autoprefixer',<% } %><% if (includeRequireJS) { %>
'requirejs',<% } %>
'cssmin',
'concat',
'uglify',
'copy',
'copy:dist',
'rev',
'usemin'
]);
Expand Down
1 change: 1 addition & 0 deletions app/templates/_package.json
Expand Up @@ -20,6 +20,7 @@
"grunt-contrib-watch": "~0.4.0",<% if (testFramework === 'jasmine') { %>
"grunt-contrib-jasmine": "~0.4.2",<% } %>
"grunt-rev": "~0.1.0",
"grunt-autoprefixer": "~0.1.20130516",
"grunt-usemin": "~0.1.10",<% if (testFramework === 'mocha') { %>
"grunt-mocha": "~0.3.0",<% } %>
"grunt-open": "~0.2.0",
Expand Down
6 changes: 4 additions & 2 deletions test/test.js
Expand Up @@ -43,7 +43,8 @@ describe('Webapp generator test', function () {

helpers.mockPrompt(this.webapp, {
'compassBootstrap': 'Y',
'includeRequireJS': 'N'
'includeRequireJS': 'N',
'autoprefixer': 'N'
});

this.webapp.options['skip-install'] = true;
Expand All @@ -68,7 +69,8 @@ describe('Webapp generator test', function () {

helpers.mockPrompt(this.webapp, {
'compassBootstrap': 'Y',
'includeRequireJS': 'Y'
'includeRequireJS': 'Y',
'autoprefixer': 'N'
});

this.webapp.options['skip-install'] = true;
Expand Down

0 comments on commit 4fcdc36

Please sign in to comment.