Commit 3892594b authored by Arthur Verschaeve's avatar Arthur Verschaeve

Fix code style in `gulpfile.js`

parent 06554414
...@@ -9,82 +9,82 @@ var pagespeed = require('psi'); ...@@ -9,82 +9,82 @@ var pagespeed = require('psi');
var app = require('./server'); var app = require('./server');
var AUTOPREFIXER_BROWSERS = [ var AUTOPREFIXER_BROWSERS = [
'ie >= 10', 'ie >= 10',
'ie_mob >= 10', 'ie_mob >= 10',
'ff >= 30', 'ff >= 30',
'chrome >= 34', 'chrome >= 34',
'safari >= 7', 'safari >= 7',
'opera >= 23', 'opera >= 23',
'ios >= 7', 'ios >= 7',
'android >= 4.4', 'android >= 4.4',
'bb >= 10' 'bb >= 10'
]; ];
// Lint JavaScript // Lint JavaScript
gulp.task('jshint', function () { gulp.task('jshint', function () {
return gulp.src('site-assets/*.js') return gulp.src('site-assets/*.js')
.pipe($.jshint()) .pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish')); .pipe($.jshint.reporter('jshint-stylish'));
}); });
// Optimize Images // Optimize Images
gulp.task('images', function () { gulp.task('images', function () {
return gulp.src('site-assets/*.{png,jpg,svg}') return gulp.src('site-assets/*.{png,jpg,svg}')
.pipe($.cache($.imagemin({ .pipe($.cache($.imagemin({
progressive: true, progressive: true,
interlaced: true interlaced: true
}))) })))
.pipe(gulp.dest('dist/site-assets')) .pipe(gulp.dest('dist/site-assets'))
.pipe($.size({title: 'images'})); .pipe($.size({title: 'images'}));
}); });
// Copy All Files At The Root Level (app) // Copy All Files At The Root Level (app)
gulp.task('copy', function () { gulp.task('copy', function () {
return gulp.src([ return gulp.src([
'examples/**', 'examples/**',
'bower_components/**', 'bower_components/**',
'learn.json', 'learn.json',
'CNAME', 'CNAME',
'.nojekyll', '.nojekyll',
'site-assets/favicon.ico' 'site-assets/favicon.ico'
], { ], {
dot: true, dot: true,
base: './' base: './'
}).pipe(gulp.dest('dist')) }).pipe(gulp.dest('dist'))
.pipe($.size({title: 'copy'})); .pipe($.size({title: 'copy'}));
}); });
// Compile and Automatically Prefix Stylesheets // Compile and Automatically Prefix Stylesheets
gulp.task('styles', function () { gulp.task('styles', function () {
// For best performance, don't add Sass partials to `gulp.src` // For best performance, don't add Sass partials to `gulp.src`
return gulp.src([ return gulp.src([
'site-assets/*.css', 'site-assets/*.css'
]) ])
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS)) .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('dist/site-assets')) .pipe(gulp.dest('dist/site-assets'))
.pipe($.size({title: 'styles'})) .pipe($.size({title: 'styles'}))
.pipe(gulp.dest('.tmp/site-assets')); .pipe(gulp.dest('.tmp/site-assets'));
}); });
// Scan Your HTML For Assets & Optimize Them // Scan Your HTML For Assets & Optimize Them
gulp.task('html', function () { gulp.task('html', function () {
var assets = $.useref.assets({searchPath: '{.tmp,.}'}); var assets = $.useref.assets({searchPath: '{.tmp,.}'});
return gulp.src('index.html') return gulp.src('index.html')
.pipe(assets) .pipe(assets)
// Concatenate And Minify JavaScript // Concatenate And Minify JavaScript
.pipe($.if('*.js', $.uglify({preserveComments: 'some'}))) .pipe($.if('*.js', $.uglify({preserveComments: 'some'})))
// Concatenate And Minify Styles // Concatenate And Minify Styles
.pipe($.if('*.css', $.csso())) .pipe($.if('*.css', $.csso()))
.pipe(assets.restore()) .pipe(assets.restore())
.pipe($.useref()) .pipe($.useref())
// Output Files // Output Files
.pipe(gulp.dest('dist')) .pipe(gulp.dest('dist'))
// Running vulcanize over the written output // Running vulcanize over the written output
// because it requires access to the written // because it requires access to the written
// CSS and JS. // CSS and JS.
.pipe($.vulcanize({ dest: 'dist', strip: true })) .pipe($.vulcanize({ dest: 'dist', strip: true }))
.pipe($.size({title: 'html'})); .pipe($.size({title: 'html'}));
}); });
// Clean Output Directory // Clean Output Directory
...@@ -92,20 +92,20 @@ gulp.task('clean', del.bind(null, ['.tmp', 'dist'])); ...@@ -92,20 +92,20 @@ gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
// Build Production Files, the Default Task // Build Production Files, the Default Task
gulp.task('default', ['clean'], function (cb) { gulp.task('default', ['clean'], function (cb) {
runSequence(['styles', 'copy'], ['jshint', 'html', 'images'], cb); runSequence(['styles', 'copy'], ['jshint', 'html', 'images'], cb);
}); });
// Run PageSpeed Insights // Run PageSpeed Insights
// Update `url` below to the public URL for your site // Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, { gulp.task('pagespeed', pagespeed.bind(null, {
// By default, we use the PageSpeed Insights // By default, we use the PageSpeed Insights
// free (no API key) tier. You can use a Google // free (no API key) tier. You can use a Google
// Developer API key if you have one. See // Developer API key if you have one. See
// http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY' // http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
url: 'https://todomvc.com', url: 'https://todomvc.com',
strategy: 'mobile' strategy: 'mobile'
})); }));
gulp.task('serve', function (cb) { gulp.task('serve', function (cb) {
app.listen(8080, cb); app.listen(8080, cb);
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment