Commit 2e65d73d authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] make css minification optional

parent ca47848c
......@@ -29,6 +29,10 @@ module.exports = yeoman.generators.Base.extend((function() {
jsConcatSuggestions = {
standalone: true,
typo3Frontend: false
},
cssMinifySuggestions = {
standalone: true,
typo3Frontend: false
};
Generator.initializing = function() {
......@@ -121,6 +125,21 @@ module.exports = yeoman.generators.Base.extend((function() {
});
}
},
cssPrompts: function() {
var done = this.async();
this.prompt([
{
type: 'confirm',
name: 'minifyCss',
message: 'Do you want to include minification for CSS files?',
default: cssMinifySuggestions[answers.projectType]
}
], function(_answers) {
answers = _.extend(answers, _answers);
done();
});
},
javascriptPrompts: function() {
if (answers.projectType !== 'extbaseExtension') {
var done = this.async();
......
......@@ -10,13 +10,13 @@
"gulp": "^3.8.10",
"gulp-autoprefixer": "^2.0.0",
"gulp-compass": "^2.0.3",
"gulp-cssimport": "^1.3.1",
"gulp-minify-css": "^0.3.11",
"gulp-cssimport": "^1.3.1",<% if (minifyCss) { %>
"gulp-minify-css": "^0.3.11",<% } %>
"gulp-imagemin": "^2.1.0",
"gulp-jshint": "^1.9.0",
"jshint-stylish": "^1.0.0",<% if (browserify) { %>
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0",
"browserify": "^8.1.0",<% } else if (jsconcat) { %>
"gulp-concat": "^2.4.3",<% } %><% if (jsuglify) { %>
"gulp-uglify": "^1.0.2",<% } %>
......
......@@ -4,8 +4,8 @@ var gulp = require('gulp'),
settings = require('./settings'),
compass = require('gulp-compass'),
cssImport = require('gulp-cssimport'),
autoprefixer = require('gulp-autoprefixer'),
minifyCss = require('gulp-minify-css')<% if (livereloadMethod === 'browserSync') { %>,
autoprefixer = require('gulp-autoprefixer')<% if (minifyCss) { %>,
minifyCss = require('gulp-minify-css')<% } %><% if (livereloadMethod === 'browserSync') { %>,
browserSync = require('browser-sync')<% } %>;
// compile sass to css
......@@ -18,8 +18,8 @@ gulp.task('css', function() {
sass: settings.path.sass
}))
.pipe(cssImport())
.pipe(autoprefixer(<%= autoprefixerBrowserSelection %>))
.pipe(minifyCss())
.pipe(autoprefixer(<%= autoprefixerBrowserSelection %>))<% if (minifyCss) { %>
.pipe(minifyCss())<% } %>
.pipe(gulp.dest(settings.path.css))<% if (livereloadMethod === 'browserSync') { %>
.pipe(browserSync.reload({stream: true}))<% } %>;
});
/*global describe, beforeEach, it */
'use strict';
var path = require('path'),
assert = assert = require('yeoman-generator').assert,
helpers = require('yeoman-generator').test,
os = require('os'),
fs = require('fs');
describe('sgalinski generator:standalone:cssMinify', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'standalone',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
compassConfigPath: '.',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\'',
minifyCss: true
})
.on('end', done);
});
it('includes concat task', function() {
assert.fileContent('gulp/css.js', 'minifyCss()');
assert.fileContent('package.json', '"gulp-minify-css":');
});
});
describe('sgalinski generator:standalone:withoutCssMinify', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'standalone',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
compassConfigPath: '.',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\'',
minifyCss: false
})
.on('end', done);
});
it('includes concat task', function() {
assert.noFileContent('gulp/css.js', 'minifyCss()');
assert.noFileContent('package.json', '"gulp-minify-css":');
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment