Commit fcf3fe2c authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] make compass optional and offer libsass as alternative

parent 2e65d73d
......@@ -104,12 +104,6 @@ module.exports = yeoman.generators.Base.extend((function() {
message: 'Please specify the path to the javascript files',
default: resourcePathsSuggestions[answers.projectType].javascriptPath
},
{
type: 'input',
name: 'compassConfigPath',
message: 'Please specify the path to config.rb file for compass',
default: '.'
},
{
type: 'input',
name: 'imagesPath',
......@@ -129,6 +123,20 @@ module.exports = yeoman.generators.Base.extend((function() {
var done = this.async();
this.prompt([
{
type: 'confirm',
name: 'compass',
message: 'Do you want to include compass?',
default: false
},
{
when: function(answers) { return answers.compass; },
type: 'input',
name: 'compassConfigPath',
message: 'Please specify the path to config.rb file for compass',
default: '.'
},
{
when: function() { return answers.projectType !== 'extbaseExtension'; },
type: 'confirm',
name: 'minifyCss',
message: 'Do you want to include minification for CSS files?',
......@@ -257,7 +265,7 @@ module.exports = yeoman.generators.Base.extend((function() {
};
Generator.writeCompassConfig = function() {
if (answers.projectType !== 'typo3Frontend') {
if (answers.projectType !== 'typo3Frontend' && answers.compass) {
this.fs.copyTpl(
this.templatePath('_config.rb'),
this.destinationPath(answers.compassConfigPath + '/config.rb'),
......
{
"css": "<%= cssPath %>",
"sass": "<%= sassPath %>",
"javascript": "<%= javascriptPath %>",
"compassConfig": "<%= compassConfigPath %>",
"javascript": "<%= javascriptPath %>",<% if (compass) { %>
"compassConfig": "<%= compassConfigPath %>",<% } %>
"images": "<%= imagesPath %>"
}
......@@ -8,8 +8,9 @@
"browser-sync": "^1.8.2",<% } else if (livereloadMethod === 'livereload') { %>
"gulp-livereload": "^3.2.0",<% } %>
"gulp": "^3.8.10",
"gulp-autoprefixer": "^2.0.0",
"gulp-compass": "^2.0.3",
"gulp-autoprefixer": "^2.0.0",<% if (compass) { %>
"gulp-compass": "^2.0.3",<% } else { %>
"gulp-sass": "^1.3.1",<% } %>
"gulp-cssimport": "^1.3.1",<% if (minifyCss) { %>
"gulp-minify-css": "^0.3.11",<% } %>
"gulp-imagemin": "^2.1.0",
......
'use strict';
var gulp = require('gulp'),
settings = require('./settings'),
compass = require('gulp-compass'),
settings = require('./settings'),<% if (compass) { %>
compass = require('gulp-compass'),<% } else { %>
sass = require('gulp-sass'),<% } %>
cssImport = require('gulp-cssimport'),
autoprefixer = require('gulp-autoprefixer')<% if (minifyCss) { %>,
minifyCss = require('gulp-minify-css')<% } %><% if (livereloadMethod === 'browserSync') { %>,
......@@ -10,13 +11,14 @@ var gulp = require('gulp'),
// compile sass to css
gulp.task('css', function() {
return gulp.src(settings.path.sass + '/**/*.scss')
return gulp.src(settings.path.sass + '/**/*.scss')<% if (compass) { %>
.pipe(compass({
config_file: settings.path.compassConfig + '/config.rb',
sourcemap: true,
css: settings.path.css,
sass: settings.path.sass
}))
}))<% } else { %>
.pipe(sass())<% } %>
.pipe(cssImport())
.pipe(autoprefixer(<%= autoprefixerBrowserSelection %>))<% if (minifyCss) { %>
.pipe(minifyCss())<% } %>
......
......@@ -22,8 +22,8 @@ module.exports = (function() {
path: {
css: path.join(extensionPath, assetPaths.css),
sass: path.join(extensionPath, assetPaths.sass),
javascript: path.join(extensionPath, assetPaths.javascript),
compassConfig: path.join(extensionPath, assetPaths.compassConfig),
javascript: path.join(extensionPath, assetPaths.javascript),<% if (compass) { %>
compassConfig: path.join(extensionPath, assetPaths.compassConfig),<% } %>
images: path.join(extensionPath, assetPaths.images)
}
};
......@@ -33,8 +33,8 @@ module.exports = {
path: {
css: '<%= cssPath %>',
sass: '<%= sassPath %>',
javascript: '<%= javascriptPath %>',
compassConfig: '<%= compassConfigPath %>',
javascript: '<%= javascriptPath %>',<% if (compass) { %>
compassConfig: '<%= compassConfigPath %>',<% } %>
images: '<%= imagesPath %>'
}
};
......
......@@ -19,7 +19,8 @@ describe('sgalinski generator:extbase-extension', function() {
sassPath: 'sass',
javascriptPath: 'js',
compassConfigPath: '.',
imagesPath: 'imgs'
imagesPath: 'imgs',
compass: true
})
.on('end', done);
});
......
/*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:sass', 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\'',
compass: false
})
.on('end', done);
});
it('does not create config.rb', function() {
assert.noFile([
'config.rb'
]);
});
it('does require gulp-sass', function() {
assert.fileContent('package.json', '"gulp-sass":');
});
it('does create the correct gulp task', function() {
assert.fileContent('gulp/css.js', '.pipe(sass())');
assert.noFileContent('gulp/css.js', 'compass');
});
it('does exclude compassConfigPath from settings', function() {
assert.noFileContent('gulp/settings.js', 'compassConfig');
});
});
describe('sgalinski generator:extbaseExtension:sass', function() {
before(function(done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(os.tmpdir(), './temp-test'))
.withOptions({ 'skip-install': true })
.withPrompt({
projectType: 'extbaseExtension',
projectName: 'test',
cssPath: 'css',
sassPath: 'sass',
javascriptPath: 'js',
compassConfigPath: '.',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\'',
compass: false
})
.on('end', done);
});
it('does not create config.rb', function() {
assert.noFile([
'config.rb'
]);
});
it('does exclude compassConfigPath from settings', function() {
assert.noFileContent('asset-paths.json', 'compassConfig');
});
});
......@@ -20,7 +20,8 @@ describe('sgalinski generator:standalone', function() {
javascriptPath: 'js',
compassConfigPath: '.',
imagesPath: 'imgs',
autoprefixerBrowserSelection: '\'last 1 version\''
autoprefixerBrowserSelection: '\'last 1 version\'',
compass: true
})
.on('end', done);
});
......
......@@ -15,7 +15,8 @@ describe('sgalinski generator:typo3-frontend', function() {
.withPrompt({
projectType: 'typo3Frontend',
projectName: 'test',
autoprefixerBrowserSelection: '\'last 1 version\''
autoprefixerBrowserSelection: '\'last 1 version\'',
compass: true
})
.on('end', done);
});
......
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