2015-07-21 22:37:29 +02:00
|
|
|
|
|
|
|
var gulp = require('gulp'),
|
|
|
|
php = require('gulp-connect-php'),
|
|
|
|
less = require('gulp-less'),
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
plumber = require('gulp-plumber'),
|
2016-05-05 23:43:37 +02:00
|
|
|
postcss = require('gulp-postcss'),
|
|
|
|
sourcemaps = require('gulp-sourcemaps');
|
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
|
|
|
};
|
|
|
|
|
|
|
|
function createTask(source, dest) {
|
|
|
|
return function() {
|
2015-12-22 21:52:22 +01:00
|
|
|
var nano_options = {
|
|
|
|
safe: true, // Disable dangerous optimisations
|
|
|
|
filterPlugins: false, // This does very weird stuff
|
|
|
|
autoprefixer: {
|
|
|
|
add: true, // Add needed prefixes
|
|
|
|
remove: true // Remove unnecessary prefixes
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-21 22:37:29 +02:00
|
|
|
return gulp.src(source)
|
2016-05-05 23:43:37 +02:00
|
|
|
//.pipe(sourcemaps.init())
|
2015-12-22 21:52:22 +01:00
|
|
|
.pipe(plumber())
|
2015-07-21 22:37:29 +02:00
|
|
|
.pipe(less())
|
|
|
|
.pipe(postcss([
|
2015-12-22 21:52:22 +01:00
|
|
|
require('cssnano')(nano_options)
|
2015-07-21 22:37:29 +02:00
|
|
|
]))
|
|
|
|
.pipe(rename({suffix: '.min'}))
|
2016-05-05 23:43:37 +02:00
|
|
|
//.pipe(sourcemaps.write())
|
2015-07-21 22:37:29 +02:00
|
|
|
.pipe(gulp.dest(dest));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-05 23:43:37 +02:00
|
|
|
function createLinter() {
|
|
|
|
var gulpStylelint = require('gulp-stylelint');
|
|
|
|
|
|
|
|
var rules = {
|
|
|
|
"indentation": 4,
|
|
|
|
"selector-list-comma-newline-after": "always-multi-line",
|
|
|
|
"selector-no-id": true,
|
|
|
|
|
|
|
|
// 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
|
|
|
|
};
|
|
|
|
|
|
|
|
return gulp
|
|
|
|
.src(['themes/**/less/**/*.less', '!themes/**/vendor/**/*.less'])
|
|
|
|
.pipe(gulpStylelint({
|
|
|
|
failAfterError: true,
|
|
|
|
config: {
|
|
|
|
extends: "stylelint-config-standard",
|
|
|
|
rules: rules
|
|
|
|
},
|
|
|
|
syntax: "less",
|
|
|
|
reporters: [
|
|
|
|
{formatter: 'string', console: true}
|
|
|
|
],
|
|
|
|
debug: true
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-21 22:37:29 +02:00
|
|
|
|
|
|
|
var style_tasks = [];
|
|
|
|
for (var style in resources) {
|
|
|
|
gulp.task('style_' + style, createTask(resources[style].source, resources[style].dest));
|
|
|
|
style_tasks.push('style_' + style);
|
|
|
|
}
|
|
|
|
|
2016-05-05 23:43:37 +02:00
|
|
|
gulp.task('lint-css', createLinter);
|
|
|
|
style_tasks.push('lint-css');
|
|
|
|
|
2015-07-21 22:37:29 +02:00
|
|
|
gulp.task("styles", style_tasks);
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('watch', function() {
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('php', function() {
|
|
|
|
php.server({
|
|
|
|
keepalive: true,
|
|
|
|
open: true,
|
|
|
|
port: 8085,
|
|
|
|
router: "index.php"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('default', ['php']);
|