2015-12-10 16:22:20 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var path = require('path');
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var conf = require('./conf');
|
|
|
|
|
|
|
|
var browserSync = require('browser-sync');
|
|
|
|
|
|
|
|
var $ = require('gulp-load-plugins')();
|
|
|
|
|
|
|
|
var wiredep = require('wiredep').stream;
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
2016-01-12 16:35:53 +00:00
|
|
|
gulp.task('styles-reload', ['styles'], function () {
|
2015-12-14 18:22:38 +00:00
|
|
|
return buildStyles()
|
|
|
|
.pipe(browserSync.stream());
|
|
|
|
});
|
|
|
|
|
2016-01-12 16:35:53 +00:00
|
|
|
gulp.task('styles', function () {
|
2015-12-14 18:22:38 +00:00
|
|
|
return buildStyles();
|
|
|
|
});
|
|
|
|
|
2016-01-12 16:35:53 +00:00
|
|
|
gulp.task('stylesAuth', function () {
|
2016-01-12 16:45:49 +00:00
|
|
|
return buildSingleScss(path.join(conf.paths.src, '/sass/auth.scss'));
|
2016-01-12 16:35:53 +00:00
|
|
|
});
|
|
|
|
gulp.task('styles404', function () {
|
2016-01-12 16:45:49 +00:00
|
|
|
return buildSingleScss(path.join(conf.paths.src, '/sass/404.scss'));
|
2016-01-12 16:35:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var buildStyles = function () {
|
2015-12-10 16:22:20 +00:00
|
|
|
var sassOptions = {
|
|
|
|
style: 'expanded'
|
|
|
|
};
|
|
|
|
|
|
|
|
var injectFiles = gulp.src([
|
2015-12-15 18:06:42 +00:00
|
|
|
path.join(conf.paths.src, '/sass/**/_*.scss'),
|
2016-01-12 16:35:53 +00:00
|
|
|
'!' + path.join(conf.paths.src, '/sass/theme/conf/**/*.scss'),
|
|
|
|
'!' + path.join(conf.paths.src, '/sass/404.scss'),
|
|
|
|
'!' + path.join(conf.paths.src, '/sass/auth.scss')
|
|
|
|
], {read: false});
|
2015-12-10 16:22:20 +00:00
|
|
|
|
|
|
|
var injectOptions = {
|
2016-01-12 16:35:53 +00:00
|
|
|
transform: function (filePath) {
|
2015-12-15 15:51:53 +00:00
|
|
|
filePath = filePath.replace(conf.paths.src + '/sass/', '');
|
|
|
|
return '@import "' + filePath + '";';
|
2015-12-10 16:22:20 +00:00
|
|
|
},
|
|
|
|
starttag: '// injector',
|
|
|
|
endtag: '// endinjector',
|
|
|
|
addRootSlash: false
|
|
|
|
};
|
|
|
|
|
|
|
|
return gulp.src([
|
2015-12-15 15:51:53 +00:00
|
|
|
path.join(conf.paths.src, '/sass/main.scss')
|
2015-12-10 16:22:20 +00:00
|
|
|
])
|
2015-12-15 15:51:53 +00:00
|
|
|
.pipe($.inject(injectFiles, injectOptions))
|
2015-12-10 16:22:20 +00:00
|
|
|
.pipe(wiredep(_.extend({}, conf.wiredep)))
|
|
|
|
.pipe($.sourcemaps.init())
|
|
|
|
.pipe($.sass(sassOptions)).on('error', conf.errorHandler('Sass'))
|
|
|
|
.pipe($.autoprefixer()).on('error', conf.errorHandler('Autoprefixer'))
|
|
|
|
.pipe($.sourcemaps.write())
|
2015-12-14 18:22:38 +00:00
|
|
|
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/')));
|
|
|
|
};
|
2016-01-12 16:35:53 +00:00
|
|
|
|
2016-01-12 16:45:49 +00:00
|
|
|
var buildSingleScss = function (paths) {
|
2016-01-12 16:35:53 +00:00
|
|
|
var sassOptions = {
|
|
|
|
style: 'expanded'
|
|
|
|
};
|
|
|
|
|
|
|
|
return gulp.src([paths])
|
|
|
|
.pipe($.sass(sassOptions)).on('error', conf.errorHandler('Sass'))
|
|
|
|
.pipe($.autoprefixer()).on('error', conf.errorHandler('Autoprefixer'))
|
|
|
|
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/')));
|
|
|
|
};
|