You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.5 KiB

6 years ago
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var imagemin = require('gulp-imagemin');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
6 years ago
var autoprefixer = require('gulp-autoprefixer');
6 years ago
var sourcemaps = require('gulp-sourcemaps');
6 years ago
var concat = require('gulp-concat');
6 years ago
//var cache = require('gulp-cache');
//===================
// Browsersync Proxy
//===================
6 years ago
gulp.task('browser-sync', function() {
6 years ago
browserSync.init({
proxy: "https://journaloflmmontgomerystudies.ca",
6 years ago
serveStatic: ['.'],
files: ['./css/style.css','./js/js.js'],
plugins: ['bs-rewrite-rules'],
rewriteRules: [
{
6 years ago
match: '/themes/custom/lmmi_journal/js/',
replace: '/js/'
},
{
match: '/themes/custom/lmmi_journal/css/',
replace: '/css/'
6 years ago
}
]
});
6 years ago
});
6 years ago
//====================
// Sass Compilation
//===================
gulp.task('sass', function () {
return gulp.src('./src/scss/**/*.scss')
6 years ago
.pipe(sass({
includePaths: ['./node_modules/breakpoint-sass/stylesheets']
}))
6 years ago
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('.'))
6 years ago
.pipe(gulp.dest('./css'));
6 years ago
});
6 years ago
//====================
// JS Concatination
//===================
gulp.task('js', function () {
gulp.src('./src/js/*.js') // path to your files
.pipe(concat('js.js')) // concat and name it "concat.js"
.pipe(gulp.dest('./js/'));
6 years ago
});
6 years ago
//====================
// Image Optimization
//===================
gulp.task('images', function(){
gulp.src('src/img/**/*')
//.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(imagemin([
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
})
]))
.pipe(gulp.dest('img/'));
6 years ago
});
6 years ago
//==================
// Default Gulp Task
//=================
gulp.task ('default',['browser-sync'], function(){
//watch sass folder and compile changes
gulp.watch('src/scss/**/*.scss', ['sass']);
//watch js folder and compile changes
gulp.watch('src/js/**/*.js', ['js']);
//watch image folder and optimize
gulp.watch('src/img/**/*', ['images']);
6 years ago
});
6 years ago