-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
73 lines (62 loc) · 1.9 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Created by orhanveli on 26/08/16.
*/
var gulp = require("gulp"),
sass = require("gulp-sass"),
useref = require("gulp-useref"),
uglify = require("gulp-uglify"),
cssnano = require("gulp-cssnano"),
rename = require("gulp-rename"),
sourcemaps = require("gulp-sourcemaps"),
runSequence = require("run-sequence"),
webserver = require("gulp-webserver");
function minJsTask(){
return gulp.src(["dist/js/*.js", "!dist/js/*.min.js"])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest("dist/js"));
}
function sassTask(){
return gulp.src("src/scss/medium-editor-embed-button.scss")
.pipe(sass())
.pipe(gulp.dest("src/css"));
}
function minCssTask(){
return gulp.src(["dist/**/[^_]*.css", "!dist/**/*.min.css"])
.pipe(sourcemaps.init())
.pipe(cssnano())
.pipe(sourcemaps.write('.'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest("dist"));
}
function userefTask(){
return gulp.src("src/sample/*.html")
.pipe(useref())
//.pipe(gulpIf("*.js", uglify()))
//.pipe(gulpIf("*.css", cssnano()))
.pipe(gulp.dest("dist/sample"));
}
function watchTask(){
gulp.watch(["src/scss/**/*.scss", "src/js/**/*.js", "src/sample/**/*"], ["dist"]);
}
function webserverTask(){
gulp.src("src")
.pipe(webserver({
livereload: true,
directoryListing: true,
port: 8088,
open: "http://localhost:8088/sample/index.html"
}));
}
gulp.task("min:js", minJsTask);
gulp.task("min:css", ["sass"], minCssTask);
gulp.task("min", ["min:css", "min:js"]);
gulp.task("sass", sassTask);
gulp.task("useref", ["sass"], userefTask);
gulp.task("watch", watchTask);
gulp.task("serve", webserverTask);
gulp.task("dist", function(){
runSequence("useref", "min");
});