Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Refactor style tasks #153 #155

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 28 additions & 48 deletions app/templates/gulpfile.js
Expand Up @@ -9,6 +9,7 @@ var browserSync = require('browser-sync');
var pagespeed = require('psi');
var reload = browserSync.reload;
var merge = require('merge-stream');
var path = require('path');

var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
Expand All @@ -22,6 +23,31 @@ var AUTOPREFIXER_BROWSERS = [
'bb >= 10'
];

var styleTask = function (stylesPath, srcs) {
return gulp.src(srcs.map(function(src) {
return path.join('app', stylesPath, src);
}))<% if (includeSass) {%>
.pipe($.changed(stylesPath, {extension: '.scss'}))<% } else {%>
.pipe($.changed(stylesPath, {extension: '.css'}))<% } %><% if (includeSass && includeLibSass) {%>
.pipe($.sourcemaps.init())
.pipe($.sass({
onError: console.error.bind(console)
}))
.pipe($.sourcemaps.write())
<% } else if (includeSass && includeRubySass) { %>
.pipe($.rubySass({
style: 'expanded',
precision: 10
})
.on('error', console.error.bind(console))
)<% } %>
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('.tmp/' + stylesPath))
.pipe($.if('*.css', $.cssmin()))
.pipe(gulp.dest('dist/' + stylesPath))
.pipe($.size({title: stylesPath}));
}

// Lint JavaScript
gulp.task('jshint', function () {
return gulp.src([
Expand Down Expand Up @@ -80,57 +106,11 @@ gulp.task('fonts', function () {

// Compile and Automatically Prefix Stylesheets
gulp.task('styles', function () {
return gulp.src([
'app/styles/**/*.css'<% if (includeSass) {%>,
'app/styles/*.scss'<% } %>
])<% if (includeSass) {%>
.pipe($.changed('styles', {extension: '.scss'}))<% } else {%>
.pipe($.changed('styles', {extension: '.css'}))<% } %><% if (includeSass && includeLibSass) {%>
.pipe($.sourcemaps.init())
.pipe($.sass({
onError: console.error.bind(console)
}))
.pipe($.sourcemaps.write())
<% } else if (includeSass && includeRubySass) { %>
.pipe($.rubySass({
style: 'expanded',
precision: 10
})
.on('error', console.error.bind(console))
)<% } %>
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('.tmp/styles'))
// Concatenate And Minify Styles
.pipe($.if('*.css', $.cssmin()))
.pipe(gulp.dest('dist/styles'))
.pipe($.size({title: 'styles'}));
return styleTask('styles', ['**/*.css'<% if (includeSass) {%>, '*.scss'<% } %>]);
});

gulp.task('elements', function () {
return gulp.src([
'app/elements/**/*.css'<% if (includeSass) {%>,
'app/elements/**/*.scss'<% } %>
])<% if (includeSass) {%>
.pipe($.changed('elements', {extension: '.scss'}))<% } else {%>
.pipe($.changed('styles', {extension: '.css'}))<% } %><% if (includeSass && includeLibSass) {%>
.pipe($.sourcemaps.init())
.pipe($.sass({
onError: console.error.bind(console)
}))
.pipe($.sourcemaps.write())
<% } else if (includeSass && includeRubySass) {%>
.pipe($.rubySass({
style: 'expanded',
precision: 10
})
.on('error', console.error.bind(console))
)<% } %>
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('.tmp/elements'))
// Concatenate And Minify Styles
.pipe($.if('*.css', $.cssmin()))
.pipe(gulp.dest('dist/elements'))
.pipe($.size({title: 'elements'}));
return styleTask('elements', ['**/*.css'<% if (includeSass) {%>, '**/*.scss'<% } %>]);
});

// Scan Your HTML For Assets & Optimize Them
Expand Down