Skip to content

Commit

Permalink
Gulpfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nuovecode committed May 17, 2016
0 parents commit 6f6e461
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
var gulp = require('gulp'),
less = require('gulp-less'),
gutil = require('gulp-util'),
chalk = require('chalk'),
less = require('gulp-less-sourcemap'),
clean = require('gulp-clean'),
run = require('gulp-run'),

themesConfig = require('./dev/tools/grunt/configs/themes');

var options = ((process.argv.slice(2))[1]).substring(2);

gulp.task('watch', function() {
var theme = themesConfig[options];
gulp.watch(['./vendor/' + theme.name + '/**/*.less'], ['css']);
});


gulp.task('css', function() {
var theme = themesConfig[options];
var filesToCompile = [];

theme.files.forEach(function(file) {
filesToCompile.push(
'./pub/static/' + theme.area + '/' + theme.name + '/' + theme.locale + '/' + file + '.' + theme.dsl
);
});

return gulp
.src(filesToCompile)
.pipe(less().on('error', function (error) {
gutil.log(chalk.red('Error compiling LESS: ' + error.message));
}))
.pipe(gulp.dest('./pub/static/' + theme.area + '/' + theme.name + '/' + theme.locale + '/css'))
.pipe(gutil.buffer(function() {
gutil.log(chalk.green('Successfully compiled LESS'));
}));
});

gulp.task('build', function() {

var theme = themesConfig[options];
var cmd = 'bin/magento dev:source-theme:deploy --theme ' + theme.name + ' --locale ' + theme.locale;
var folderToClean = [
'./pub/static/' + theme.area + '/' + theme.name + '/*',
'./var/view_preprocessed/*',
'./var/cache/*'
];

return gulp.src(folderToClean, {read: false})
.pipe(clean())
.pipe(gutil.buffer(function() {
gutil.log(chalk.green('Clean..'));
}))
.pipe(run(cmd))
.pipe(gutil.buffer(function() {
gutil.log(chalk.green('Successfully build ' + theme.name ));
}));

});

gulp.task('default', ['watch']);

0 comments on commit 6f6e461

Please sign in to comment.