Last active
April 20, 2016 09:44
-
-
Save ArnaudBan/bcd2ad1d036a14991e84 to your computer and use it in GitHub Desktop.
Ma confige Gulp
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
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
cssnano = require('gulp-cssnano'), | |
rename = require('gulp-rename'), | |
uglify = require('gulp-uglify'), | |
concat = require('gulp-concat'), | |
plumber = require('gulp-plumber'); | |
var browserSync = require('browser-sync').create(); | |
gulp.task('styles', function() { | |
// Sass watch, autoprefixr, minify and rename | |
return gulp.src('scss/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(autoprefixer('last 2 version')) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(cssnano()) | |
.pipe(gulp.dest('css')) | |
// Live reload for styles | |
.pipe(browserSync.stream()); | |
}); | |
// JS concat and minify | |
gulp.task('scripts', function() { | |
gulp.src(['js/*.js']) | |
.pipe(plumber()) | |
.pipe(concat('scripts.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('minjs')) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('scss/*.scss', ['styles']); | |
gulp.watch('js/*.js', ['scripts']); | |
// Live reload for php files | |
gulp.watch(['*.php']) | |
.on('change', browserSync.reload); | |
}); | |
gulp.task('browser-sync', function() { | |
browserSync.init({ | |
proxy: "{project}.dev" | |
}); | |
}); | |
gulp.task('default', ['watch', 'styles', 'scripts', 'browser-sync'], function() { | |
}); |
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
{ | |
"name": "{project}", | |
"version": "1.0.0", | |
"description": "Site Web {project}", | |
"main": "gulpfile.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "ArnaudBan", | |
"license": "ISC", | |
"dependencies": {}, | |
"devDependencies": { | |
"browser-sync": "^2.11.1", | |
"gulp": "^3.9.1", | |
"gulp-autoprefixer": "^3.1.0", | |
"gulp-concat": "^2.6.0", | |
"gulp-cssnano": "^2.1.0", | |
"gulp-plumber": "^1.0.1", | |
"gulp-rename": "^1.2.2", | |
"gulp-sass": "^2.1.1", | |
"gulp-uglify": "^1.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment