2016-08-06 00:14:15 +02:00
|
|
|
var cssnano = require('cssnano'),
|
|
|
|
gulp = require('gulp'),
|
2015-07-21 22:37:29 +02:00
|
|
|
less = require('gulp-less'),
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
plumber = require('gulp-plumber'),
|
2016-05-05 23:43:37 +02:00
|
|
|
postcss = require('gulp-postcss'),
|
2016-08-06 00:14:15 +02:00
|
|
|
stylelint = require('gulp-stylelint');
|
2015-07-21 22:37:29 +02:00
|
|
|
|
|
|
|
var resources = {
|
2015-08-09 23:06:50 +02:00
|
|
|
daux_blue:{source: "themes/daux/less/theme-blue.less", dest: "themes/daux/css/"},
|
|
|
|
daux_green:{source: "themes/daux/less/theme-green.less", dest: "themes/daux/css/"},
|
|
|
|
daux_navy:{source: "themes/daux/less/theme-navy.less", dest: "themes/daux/css/"},
|
2015-11-06 22:44:34 +01:00
|
|
|
daux_red:{source: "themes/daux/less/theme-red.less", dest: "themes/daux/css/"},
|
2016-05-23 20:09:15 +02:00
|
|
|
|
2015-11-06 22:44:34 +01:00
|
|
|
daux_singlepage:{source: "themes/daux_singlepage/less/main.less", dest: "themes/daux_singlepage/css/"}
|
2015-07-21 22:37:29 +02:00
|
|
|
};
|
|
|
|
|
2016-08-06 00:14:15 +02:00
|
|
|
var stylelintRules = {
|
|
|
|
"indentation": 4,
|
|
|
|
"selector-list-comma-newline-after": "always-multi-line",
|
2017-09-13 23:27:19 +02:00
|
|
|
"selector-max-id": 0,
|
2016-08-06 00:14:15 +02:00
|
|
|
|
|
|
|
// Autoprefixer
|
|
|
|
"at-rule-no-vendor-prefix": true,
|
|
|
|
"media-feature-name-no-vendor-prefix": true,
|
|
|
|
"property-no-vendor-prefix": true,
|
|
|
|
"selector-no-vendor-prefix": true,
|
|
|
|
"value-no-vendor-prefix": true
|
|
|
|
};
|
|
|
|
|
|
|
|
var cssnanoOptions = {
|
|
|
|
safe: true, // Disable dangerous optimisations
|
|
|
|
filterPlugins: false, // This does very weird stuff
|
|
|
|
autoprefixer: {
|
|
|
|
add: true, // Add needed prefixes
|
|
|
|
remove: true // Remove unnecessary prefixes
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function createCSSTask(source, dest) {
|
|
|
|
return function () {
|
2015-07-21 22:37:29 +02:00
|
|
|
return gulp.src(source)
|
2015-12-22 21:52:22 +01:00
|
|
|
.pipe(plumber())
|
2015-07-21 22:37:29 +02:00
|
|
|
.pipe(less())
|
2016-08-06 00:14:15 +02:00
|
|
|
.pipe(postcss([cssnano(cssnanoOptions)]))
|
2015-07-21 22:37:29 +02:00
|
|
|
.pipe(rename({suffix: '.min'}))
|
|
|
|
.pipe(gulp.dest(dest));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-06 00:14:15 +02:00
|
|
|
gulp.task('lint-css', function () {
|
2016-05-05 23:43:37 +02:00
|
|
|
return gulp
|
|
|
|
.src(['themes/**/less/**/*.less', '!themes/**/vendor/**/*.less'])
|
2016-08-06 00:14:15 +02:00
|
|
|
.pipe(stylelint({
|
2016-05-05 23:43:37 +02:00
|
|
|
failAfterError: true,
|
|
|
|
config: {
|
2016-08-06 00:14:15 +02:00
|
|
|
extends: 'stylelint-config-standard',
|
|
|
|
rules: stylelintRules
|
2016-05-05 23:43:37 +02:00
|
|
|
},
|
2016-08-06 00:14:15 +02:00
|
|
|
syntax: 'less',
|
|
|
|
reporters: [{
|
|
|
|
formatter: 'string',
|
|
|
|
console: true
|
|
|
|
}],
|
2016-05-05 23:43:37 +02:00
|
|
|
debug: true
|
|
|
|
}));
|
2016-08-06 00:14:15 +02:00
|
|
|
});
|
2015-07-21 22:37:29 +02:00
|
|
|
|
|
|
|
var style_tasks = [];
|
|
|
|
for (var style in resources) {
|
2016-07-29 22:38:03 +02:00
|
|
|
if (resources.hasOwnProperty(style)) {
|
2016-08-06 00:14:15 +02:00
|
|
|
gulp.task('style_' + style, createCSSTask(resources[style].source, resources[style].dest));
|
2016-07-29 22:38:03 +02:00
|
|
|
style_tasks.push('style_' + style);
|
|
|
|
}
|
2015-07-21 22:37:29 +02:00
|
|
|
}
|
|
|
|
|
2016-05-05 23:43:37 +02:00
|
|
|
style_tasks.push('lint-css');
|
|
|
|
|
2015-07-21 22:37:29 +02:00
|
|
|
gulp.task("styles", style_tasks);
|
|
|
|
|
2017-02-23 23:15:07 +01:00
|
|
|
gulp.task('watch', ['default'], function () {
|
2015-07-21 22:37:29 +02:00
|
|
|
// Watch .less files
|
2016-05-05 23:43:37 +02:00
|
|
|
gulp.watch('themes/**/less/**/*.less', ['styles']);
|
2015-07-21 22:37:29 +02:00
|
|
|
});
|
|
|
|
|
2016-08-06 00:14:15 +02:00
|
|
|
gulp.task('default', ['styles']);
|