-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
38 lines (33 loc) · 1.06 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
server = lr();
function replaceWithAssetURL( match, imgurl){
return 'background:url({{ "'+ imgurl + '" | asset_url }})';
}
gulp.task('styles', function() {
return sass('assets/_scss/')
.on('error', function (err) {
console.error('Error!', err.message);
})
.pipe(autoprefixer())
.pipe(minifycss())
.pipe(rename({extname: '.css.liquid'}))
.pipe(replace(/background:url\((.*?)\)/g, replaceWithAssetURL))
.pipe(gulp.dest('assets/'));
});
gulp.task('watch', function() {
// Listen on port 35729
server.listen(35729, function (err) {
if (err) {
return console.log(err)
};
// Watch .scss files
gulp.watch(['assets/_scss/*.scss','assets/_scss/**/*.scss'], ['styles']);
});
});