material-design-lite/gulpfile.js

107 lines
2.8 KiB
JavaScript
Raw Normal View History

2014-04-17 05:02:38 -07:00
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
2014-04-17 05:02:38 -07:00
// load plugins
var $ = require('gulp-load-plugins')();
// hosted URL for your page
var hostedUrl = '';
2014-04-17 05:02:38 -07:00
gulp.task('styles', function () {
return gulp.src('app/styles/sass/styles.scss')
2014-04-17 05:02:38 -07:00
.pipe($.rubySass({
style: 'expanded'
}))
.pipe($.autoprefixer('last 1 version'))
.pipe(gulp.dest('dist/styles'))
.pipe(reload({stream: true}))
2014-04-17 05:02:38 -07:00
.pipe($.size());
});
gulp.task('scripts', function () {
return gulp.src('app/scripts/**/*.js')
.pipe($.jshint())
.pipe($.jshint.reporter($.jshintStylish))
.pipe(reload({stream: true, once: true}))
2014-04-17 05:02:38 -07:00
.pipe($.size());
});
gulp.task('html', ['styles', 'scripts'], function () {
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
return gulp.src('app/**/*.html')
2014-04-17 05:02:38 -07:00
.pipe($.useref.assets())
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.csso())
.pipe(cssFilter.restore())
.pipe($.useref.restore())
.pipe($.useref())
.pipe(gulp.dest('dist'))
.pipe($.size());
});
gulp.task('images', function () {
return gulp.src('app/images/**/*')
.pipe($.cache($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('dist/images'))
.pipe(reload({stream: true, once: true}))
2014-04-17 05:02:38 -07:00
.pipe($.size());
});
gulp.task('fonts', function () {
return gulp.src('**/*.{eot,svg,ttf,woff}')
2014-04-17 05:02:38 -07:00
.pipe($.flatten())
.pipe(gulp.dest('dist/images/icons'))
2014-04-17 05:02:38 -07:00
.pipe($.size());
});
gulp.task('pagespeed', function () {
opn('https://developers.google.com/speed/pagespeed/insights/?url=' + encodeURIComponent(hostedUrl));
});
2014-04-17 05:02:38 -07:00
gulp.task('clean', function () {
return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean());
});
gulp.task('build', ['html', 'images', 'fonts']);
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
gulp.task('serve', ['styles'], function () {
browserSync.init(null, {
server: {
baseDir: ['app', '.tmp'],
directory: true
},
debugInfo: false,
open: false,
host: 'localhost'
}, function (err, bs) {
require('opn')(bs.options.url);
console.log('Started web server on ' + bs.options.url);
});
2014-04-17 05:02:38 -07:00
});
gulp.task('watch', ['serve'], function () {
2014-04-17 05:02:38 -07:00
gulp.watch(['app/*.html'], reload);
2014-04-17 05:02:38 -07:00
gulp.watch('app/styles/**/*.scss', ['styles']);
gulp.watch('app/scripts/**/*.js', ['scripts']);
gulp.watch('app/images/**/*', ['images']);
gulp.watch('bower.json', ['wiredep']);
2014-04-17 05:02:38 -07:00
});