-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
executable file
·142 lines (122 loc) · 3.65 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
var gulp = require("gulp");
var stylus = require("gulp-stylus");
var autoprefixer = require("gulp-autoprefixer");
var browserSync = require("browser-sync");
var plumber = require("gulp-plumber");
var rename = require("gulp-rename");
var zip = require("gulp-zip");
var del = require("del");
var cleanCSS = require("gulp-clean-css");
// FILE SOURCES AND FILE OUTPUTS
var target = {
stylus_src: "neptuno.styl",
components_src: "styles/_all_components.styl",
formElements_src: "styles/_all_formElements.styl",
buildOutput: "build/",
cssOutput: "dist/css/"
};
/* STYLES TASKS */
function Styles (compress, filename = "neptuno.css") {
return gulp.src(target.stylus_src)
.pipe(plumber())
.pipe(stylus({
compress: compress
}))
.pipe(autoprefixer(
'last 2 version',
'> 1%',
'ie 8',
'ie 9',
'ios 6',
'android 4'
))
.pipe(rename(filename))
.pipe(gulp.dest(target.cssOutput));
}
gulp.task("styles", function(){
Styles(true, "neptuno.min.css");
Styles(false);
});
/* LIVERELOAD WITH BROWSER-SYNC*/
gulp.task("browserSync", function(){
return browserSync.init(["dist/**/*", "index.html"], {
server: {
host: "localhost"
},
open: true
});
});
/* WATCH TASKS */
gulp.task("watch-styles", function(){
gulp.watch(["styles/**/*.styl"], ["styles"]);
});
gulp.task("default", ["styles", "browserSync", "watch-styles"]);
// BUILD TASKS
function Components (compress, output_filename) {
return gulp.src(target.components_src)
.pipe(stylus({
compress: compress
}))
.pipe(plumber())
.pipe(autoprefixer(
'last 2 version',
'> 1%',
'ie 8',
'ie 9',
'ios 6',
'android 4'
))
.pipe(rename(output_filename))
.pipe(gulp.dest(target.buildOutput))
};
function Compress (output_filename) {
return gulp.src([`build/${output_filename}.min.css`, `build/${output_filename}.css`])
.pipe(plumber())
.pipe(zip(`${output_filename}.zip`))
.pipe(gulp.dest(target.buildOutput))
};
gulp.task("build-components", function(){
Components(false, "neptuno-components.css");
Components(true, "neptuno-components.min.css");
});
gulp.task("build-forms", function(){
Components(false, "neptuno-formElements.css");
Components(true, "neptuno-formElements.min.css");
});
gulp.task('clean', function () {
return del([
"build/neptuno-components.min.css",
"build/neptuno-components.css",
"build/neptuno-formElements.min.css",
"build/neptuno-formElements.css"
]);
});
gulp.task("compress-zip", function(){
Compress("neptuno-components");
Compress("neptuno-formElements");
gulp.src(["dist/css/*", "dist/fonts/*"], {base: "dist/"})
.pipe(zip("neptunocss.zip"))
.pipe(gulp.dest(target.buildOutput));
gulp.src(["index.html", "dist/**"], {base: "./"})
.pipe(zip("neptunocss+docs.zip"))
.pipe(gulp.dest(target.buildOutput));
});
gulp.task("build", ["build-components", "build-forms"], function(){
setTimeout(() => { gulp.start("compress-zip") }, 5000);
setTimeout(() => { gulp.start("clean") }, 6000);
});
// DIST OR DEPLOY TASKS
gulp.task("minify-css", function () {
return gulp.src("dist/css/*")
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist/css/'));
});
// gulp.task("compress-images", function(){
// gulp.src('dist/assets/img/**')
// .pipe(imagemin())
// .pipe(gulp.dest("dist/assets/img/"));
// });
gulp.task("dist", ["minify-css"]);
// gulp { browser-sync, compile-styles, watch-styles}
// gulp build { neptuno-components.zip[dev, prod], neptuno-formElements.zip[dev, prod], neptunoCSS+docs.zip[dev, prod, docs]}
// gulp dist { htmlmin, app.css min, compressImages}