-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f6e461
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); |