forked from LeaVerou/stretchy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
50 lines (43 loc) · 1.24 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
39
40
41
42
43
44
45
46
47
48
49
50
/*
Build file to concat & minify files, compile SCSS and so on.
npm install gulp gulp-util gulp-uglify gulp-rename gulp-concat gulp-sourcemaps gulp-sass --save-dev
*/
// grab our gulp packages
var gulp = require("gulp");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var sass = require("gulp-sass");
var autoprefixer = require("gulp-autoprefixer");
var sourcemaps = require("gulp-sourcemaps");
gulp.task("sass", function() {
return gulp.src(["**/*.scss", "!node_modules/**"])
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(autoprefixer({
browsers: ["last 2 versions"],
cascade: false
}))
.pipe(rename({ extname: ".css" }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("."));
});
gulp.task("minify", function() {
var u = uglify({output: {
max_line_len : 1000 // to prevent merge conflicts
}});
u.on("error", function(error) {
console.error(error);
u.end();
});
return gulp.src(["stretchy.js"])
.pipe(sourcemaps.init())
.pipe(u)
.pipe(rename("stretchy.min.js"))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("."));
});
gulp.task("watch", function() {
gulp.watch(["**/*.js"], ["minify"]);
gulp.watch(["**/*.scss"], ["sass"]);
});
gulp.task("default", ["sass", "minify"]);