mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 15:06:15 -04:00
Temp fixes to reproducing a proper gulp serve
This commit is contained in:
parent
2f99eb4e2c
commit
027cd49afb
2 changed files with 73 additions and 26 deletions
65
gulpfile.js
65
gulpfile.js
|
@ -1,9 +1,22 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Include Gulp & tools we'll use
|
// Include Gulp & tools we'll use
|
||||||
|
var autoprefixer = require('gulp-autoprefixer');
|
||||||
|
var useref = require('gulp-useref');
|
||||||
|
var vulcanize = require('vulcanize');
|
||||||
|
var size = require('gulp-size');
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var $ = require('gulp-load-plugins')();
|
var ghPages = require('gulp-gh-pages');
|
||||||
|
var gulpIf = require('gulp-if');
|
||||||
|
var jscs = require('gulp-jscs');
|
||||||
|
var jscsStylish = require('gulp-jscs-stylish');
|
||||||
|
var htmlExtract = require('gulp-html-extract');
|
||||||
|
var imagemin = require('gulp-imagemin');
|
||||||
|
var cleanCSS = require('gulp-clean-css');
|
||||||
|
var changed = require('gulp-changed');
|
||||||
var del = require('del');
|
var del = require('del');
|
||||||
|
var uglify = require('gulp-uglify');
|
||||||
|
var jshint = require('gulp-jshint');
|
||||||
var runSequence = require('run-sequence');
|
var runSequence = require('run-sequence');
|
||||||
var browserSync = require('browser-sync');
|
var browserSync = require('browser-sync');
|
||||||
var reload = browserSync.reload;
|
var reload = browserSync.reload;
|
||||||
|
@ -45,57 +58,57 @@ var styleTask = function(stylesPath, srcs) {
|
||||||
return gulp.src(srcs.map(function(src) {
|
return gulp.src(srcs.map(function(src) {
|
||||||
return path.join('app', stylesPath, src);
|
return path.join('app', stylesPath, src);
|
||||||
}))
|
}))
|
||||||
.pipe($.changed(stylesPath, {
|
.pipe(changed(stylesPath, {
|
||||||
extension: '.css'
|
extension: '.css'
|
||||||
}))
|
}))
|
||||||
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
|
.pipe(autoprefixer(AUTOPREFIXER_BROWSERS))
|
||||||
.pipe(gulp.dest('.tmp/' + stylesPath))
|
.pipe(gulp.dest('.tmp/' + stylesPath))
|
||||||
.pipe($.minifyCss())
|
.pipe(cleanCSS())
|
||||||
.pipe(gulp.dest(dist(stylesPath)))
|
.pipe(gulp.dest(dist(stylesPath)))
|
||||||
.pipe($.size({
|
.pipe(size({
|
||||||
title: stylesPath
|
title: stylesPath
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
var imageOptimizeTask = function(src, dest) {
|
var imageOptimizeTask = function(src, dest) {
|
||||||
return gulp.src(src)
|
return gulp.src(src)
|
||||||
.pipe($.imagemin({
|
.pipe(imagemin({
|
||||||
progressive: true,
|
progressive: true,
|
||||||
interlaced: true
|
interlaced: true
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(dest))
|
.pipe(gulp.dest(dest))
|
||||||
.pipe($.size({
|
.pipe(size({
|
||||||
title: 'images'
|
title: 'images'
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
var optimizeHtmlTask = function(src, dest) {
|
var optimizeHtmlTask = function(src, dest) {
|
||||||
var assets = $.useref.assets({
|
var assets = useref.assets({
|
||||||
searchPath: ['.tmp', 'app']
|
searchPath: ['.tmp', 'app']
|
||||||
});
|
});
|
||||||
|
|
||||||
return gulp.src(src)
|
return gulp.src(src)
|
||||||
.pipe(assets)
|
.pipe(assets)
|
||||||
// Concatenate and minify JavaScript
|
// Concatenate and minify JavaScript
|
||||||
.pipe($.if('*.js', $.uglify({
|
.pipe(gulpIf('*.js', uglify({
|
||||||
preserveComments: 'some'
|
preserveComments: 'some'
|
||||||
})))
|
})))
|
||||||
// Concatenate and minify styles
|
// Concatenate and minify styles
|
||||||
// In case you are still using useref build blocks
|
// In case you are still using useref build blocks
|
||||||
.pipe($.if('*.css', $.minifyCss()))
|
.pipe(gulpIf('*.css', cleanCSS()))
|
||||||
.pipe(assets.restore())
|
.pipe(assets.restore())
|
||||||
.pipe($.useref())
|
.pipe(useref())
|
||||||
// Minify any HTML
|
// Minify any HTML
|
||||||
.pipe($.if('*.html', $.minifyHtml({
|
.pipe(gulpIf('*.html', minifyHTML({
|
||||||
quotes: true,
|
quotes: true,
|
||||||
empty: true,
|
empty: true,
|
||||||
spare: true
|
spare: true
|
||||||
})))
|
})))
|
||||||
.pipe($.if('*.html', inlinesource()))
|
.pipe(gulpIf('*.html', inlinesource()))
|
||||||
.pipe(replace('window.debug = true;', ''))
|
.pipe(replace('window.debug = true;', ''))
|
||||||
// Output files
|
// Output files
|
||||||
.pipe(gulp.dest(dest))
|
.pipe(gulp.dest(dest))
|
||||||
.pipe($.size({
|
.pipe(size({
|
||||||
title: 'html'
|
title: 'html'
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
@ -134,12 +147,12 @@ gulp.task('lint', ['ensureFiles'], function() {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// JSCS has not yet a extract option
|
// JSCS has not yet a extract option
|
||||||
.pipe($.if('*.html', $.htmlExtract()))
|
.pipe(gulpIf('*.html', htmlExtract()))
|
||||||
.pipe($.jshint())
|
.pipe(jshint())
|
||||||
.pipe($.jscs())
|
.pipe(jscs())
|
||||||
.pipe($.jscsStylish.combineWithHintResults())
|
.pipe(jscsStylish.combineWithHintResults())
|
||||||
.pipe($.jshint.reporter('jshint-stylish'))
|
.pipe(jshint.reporter('jshint-stylish'))
|
||||||
.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
|
.pipe(gulpIf(!browserSync.active, jshint.reporter('fail')));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Optimize images
|
// Optimize images
|
||||||
|
@ -166,7 +179,7 @@ gulp.task('copy', function() {
|
||||||
]).pipe(gulp.dest(dist('bower_components')));
|
]).pipe(gulp.dest(dist('bower_components')));
|
||||||
|
|
||||||
return merge(app, bower)
|
return merge(app, bower)
|
||||||
.pipe($.size({
|
.pipe(size({
|
||||||
title: 'copy'
|
title: 'copy'
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -175,7 +188,7 @@ gulp.task('copy', function() {
|
||||||
gulp.task('fonts', function() {
|
gulp.task('fonts', function() {
|
||||||
return gulp.src(['app/fonts/**'])
|
return gulp.src(['app/fonts/**'])
|
||||||
.pipe(gulp.dest(dist('fonts')))
|
.pipe(gulp.dest(dist('fonts')))
|
||||||
.pipe($.size({
|
.pipe(size({
|
||||||
title: 'fonts'
|
title: 'fonts'
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -190,7 +203,7 @@ gulp.task('html', function() {
|
||||||
// Vulcanize granular configuration
|
// Vulcanize granular configuration
|
||||||
gulp.task('vulcanize', function() {
|
gulp.task('vulcanize', function() {
|
||||||
return gulp.src('app/elements/elements.html')
|
return gulp.src('app/elements/elements.html')
|
||||||
.pipe($.vulcanize({
|
.pipe(vulcanize({
|
||||||
stripComments: true,
|
stripComments: true,
|
||||||
stripExclude:['app/bower_components/font-roboto/roboto.html'],
|
stripExclude:['app/bower_components/font-roboto/roboto.html'],
|
||||||
inlineCss: true,
|
inlineCss: true,
|
||||||
|
@ -200,7 +213,7 @@ gulp.task('vulcanize', function() {
|
||||||
empty: true
|
empty: true
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(dist('elements')))
|
.pipe(gulp.dest(dist('elements')))
|
||||||
.pipe($.size({
|
.pipe(size({
|
||||||
title: 'vulcanize'
|
title: 'vulcanize'
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -329,11 +342,11 @@ gulp.task('deploy-gh-pages', function() {
|
||||||
return gulp.src(dist('**/*'))
|
return gulp.src(dist('**/*'))
|
||||||
// Check if running task from Travis CI, if so run using GH_TOKEN
|
// Check if running task from Travis CI, if so run using GH_TOKEN
|
||||||
// otherwise run using ghPages defaults.
|
// otherwise run using ghPages defaults.
|
||||||
.pipe($.if(process.env.TRAVIS === 'true', $.ghPages({
|
.pipe(gulpIf(process.env.TRAVIS === 'true', ghPages({
|
||||||
remoteUrl: 'https://$GH_TOKEN@github.com/polymerelements/polymer-starter-kit.git',
|
remoteUrl: 'https://$GH_TOKEN@github.com/polymerelements/polymer-starter-kit.git',
|
||||||
silent: true,
|
silent: true,
|
||||||
branch: 'gh-pages'
|
branch: 'gh-pages'
|
||||||
}), $.ghPages()));
|
}), ghPages()));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load tasks for web-component-tester
|
// Load tasks for web-component-tester
|
||||||
|
|
34
tasks/ensure-files.js
Normal file
34
tasks/ensure-files.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<string>} files
|
||||||
|
* @param {Function} cb
|
||||||
|
*/
|
||||||
|
|
||||||
|
function ensureFiles(files, cb) {
|
||||||
|
var missingFiles = files.reduce(function(prev, filePath) {
|
||||||
|
var fileFound = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fileFound = fs.statSync(filePath).isFile();
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
if (!fileFound) {
|
||||||
|
prev.push(filePath + ' Not Found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return prev;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (missingFiles.length) {
|
||||||
|
var err = new Error('Missing Required Files\n' + missingFiles.join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cb) {
|
||||||
|
cb(err);
|
||||||
|
} else if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ensureFiles;
|
Loading…
Add table
Add a link
Reference in a new issue