Skip to content

Instantly share code, notes, and snippets.

@nicdford
Created September 14, 2015 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdford/cd8bb264be50baa8644c to your computer and use it in GitHub Desktop.
Save nicdford/cd8bb264be50baa8644c to your computer and use it in GitHub Desktop.
An example of a setup gulpfile to help speed up setup time for gulp driven projects
var gulp = require('gulp');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var iconify = require('gulp-iconify');
var autoprefixer = require('gulp-autoprefixer');
var googleWebFonts = require('gulp-google-webfonts');
var browserSync = require( 'browser-sync' );
var reload = browserSync.reload;
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('fonts', function () {
return gulp.src('./scss/fonts/fonts.list')
.pipe(googleWebFonts())
.pipe(gulp.dest('./scss/fonts'));
});
gulp.task('icons', function() {
iconify({
src: './images/icons/*.svg',
pngOutput: './images/icons/png',
cssOutput: './scss/icons',
defaultWidth: '21px',
defaultHeight: '19px',
svgoOptions: {
enabled: true,
options: {
plugins: [
{ removeUnknownsAndDefaults: false },
{ mergePaths: false }
]
}
}
});
});
gulp.task( 'scss', function() {
return gulp.src( './scss/style.scss' )
.pipe( sass({
style: 'expanded',
sourceComments: 'normal'
}) )
.pipe( autoprefixer() )
.pipe( gulp.dest( 'dist' ) )
.pipe( reload( { stream: true } ) );
});
gulp.task('scripts', function() {
return gulp.src('js/**/*.js')
.pipe(concat('scripts.js'))
// .pipe(gulp.dest('dist'))
// .pipe(uglify())
.pipe(gulp.dest('dist'))
})
gulp.task( 'server', function() {
browserSync.init({
proxy: 'http://localhost:8888/northwest_media_site/',
notify: false
});
// Reload the browser if any .php file changes within this directory
watch( './**/*.php', reload);
// Recompile sass into CSS whenever we update any of the source files
watch( './scss/**/*.scss', function() {
gulp.start( 'scss' );
});
// Watch our JavaScript files and report any errors. May ruin your day.
watch( './js/**/*.js', function() {
gulp.start( 'scripts', reload);
})
});
gulp.task( 'default', [ 'fonts', 'scss', 'server', 'scripts' ], function() {
console.log('done');
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment