Last active
August 29, 2015 14:19
-
-
Save DenisBazhan/4f9bba109d81ca2f5fb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var gulp = require('gulp'), | |
| watch = require('gulp-watch'), | |
| prefixer = require('gulp-autoprefixer'), | |
| uglify = require('gulp-uglify'), | |
| sass = require('gulp-sass'), | |
| sourcemaps = require('gulp-sourcemaps'), | |
| spritesmith = require('gulp.spritesmith'), | |
| rigger = require('gulp-rigger'), | |
| cssmin = require('gulp-minify-css'), | |
| imageop = require('gulp-image-optimization'), | |
| rimraf = require('rimraf'), | |
| browserSync = require("browser-sync"), | |
| reload = browserSync.reload; | |
| var path = { | |
| build: { | |
| html: 'build/', | |
| js: 'build/js/', | |
| css: 'build/css/', | |
| img: 'build/img/', | |
| fonts: 'build/fonts/' | |
| }, | |
| src: { | |
| html: 'src/*.html', | |
| js: 'src/js/main.js', | |
| style: 'src/css/main.sass', | |
| img: 'src/img/**/*.*', | |
| fonts: 'src/fonts/**/*.*', | |
| css: 'src/css/' | |
| }, | |
| watch: { | |
| html: 'src/**/*.html', | |
| js: 'src/js/**/*.js', | |
| style: 'src/css/**/*.sass', | |
| img: 'src/img/**/*.*', | |
| fonts: 'src/fonts/**/*.*' | |
| }, | |
| clean: './build', | |
| bower: { | |
| compass: 'bower_components/bower-compass-core/compass/stylesheets/' | |
| } | |
| }; | |
| var config = { | |
| server: { | |
| baseDir: "./build" | |
| }, | |
| tunnel: true, | |
| host: 'localhost', | |
| port: 9000, | |
| logPrefix: "localhost" | |
| }; | |
| gulp.task('webserver', function () { | |
| browserSync(config); | |
| }); | |
| gulp.task('clean', function (cb) { | |
| rimraf(path.clean, cb); | |
| }); | |
| gulp.task('html:build', function () { | |
| gulp.src(path.src.html) | |
| .pipe(rigger()) | |
| .pipe(gulp.dest(path.build.html)) | |
| .pipe(reload({stream: true})); | |
| }); | |
| gulp.task('js:build', function () { | |
| gulp.src(path.src.js) | |
| .pipe(rigger()) | |
| .pipe(sourcemaps.init()) | |
| .pipe(uglify()) | |
| .pipe(sourcemaps.write()) | |
| .pipe(gulp.dest(path.build.js)) | |
| .pipe(reload({stream: true})); | |
| }); | |
| gulp.task('style:build', function () { | |
| gulp.src(path.src.style) | |
| .pipe(sourcemaps.init()) | |
| .pipe(sass({ | |
| compass: true, | |
| includePaths: [path.bower.compass, path.src.css], | |
| indentedSyntax: true, | |
| outputStyle: 'compressed', | |
| sourceMap: true, | |
| errLogToConsole: true | |
| })) | |
| .pipe(prefixer()) | |
| .pipe(cssmin()) | |
| .pipe(sourcemaps.write()) | |
| .pipe(gulp.dest(path.build.css)) | |
| .pipe(reload({stream: true})); | |
| }); | |
| gulp.task('image:build', function() { | |
| gulp.src(path.src.img) | |
| .pipe(imageop({ | |
| optimizationLevel: 5, | |
| progressive: true, | |
| interlaced: true | |
| })) | |
| .pipe(gulp.dest(path.build.img)) | |
| .pipe(reload({stream: true})); | |
| }); | |
| gulp.task('fonts:build', function() { | |
| gulp.src(path.src.fonts) | |
| .pipe(gulp.dest(path.build.fonts)) | |
| }); | |
| gulp.task('build', [ | |
| 'html:build', | |
| 'js:build', | |
| 'style:build', | |
| 'fonts:build', | |
| 'image:build' | |
| ]); | |
| gulp.task('watch', function(){ | |
| watch([path.watch.html], function(event, cb) { | |
| gulp.start('html:build'); | |
| }); | |
| watch([path.watch.style], function(event, cb) { | |
| gulp.start('style:build'); | |
| }); | |
| watch([path.watch.js], function(event, cb) { | |
| gulp.start('js:build'); | |
| }); | |
| watch([path.watch.img], function(event, cb) { | |
| gulp.start('image:build'); | |
| }); | |
| watch([path.watch.fonts], function(event, cb) { | |
| gulp.start('fonts:build'); | |
| }); | |
| }); | |
| gulp.task('default', ['build', 'webserver', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment