Minor improvements on gulpfile.

This commit is contained in:
Andrey Antukh 2016-04-03 13:19:11 +03:00
parent 71fb8f0a42
commit 2f6c632476
4 changed files with 64 additions and 33 deletions

View file

@ -16,20 +16,42 @@ paths.dist = "./dist/";
paths.target = "./target/"; paths.target = "./target/";
paths.scss = paths.app + "styles/**/*.scss"; paths.scss = paths.app + "styles/**/*.scss";
gulp.task("scss", function() { function makeAutoprefixer() {
return gulp.src(paths.app + "styles/main.scss") return autoprefixer('last 2 version',
'safari 5',
'ios 6',
'android 4');
}
function scssPipeline(options) {
var input = options.input;
var output = options.output;
return gulp.src(input)
.pipe(plumber()) .pipe(plumber())
.pipe(scss({style: "expanded"})) .pipe(scss({style: "expanded"}))
.pipe(gulp.dest(paths.output + "css/")); .pipe(makeAutoprefixer())
.pipe(gulp.dest(output));
}
gulp.task("scss:theme-light", function() {
return scssPipeline({
input: paths.app + "styles/main.scss",
output: paths.output + "css/"
});
}); });
gulp.task("autoprefixer", function() { // gulp.task("scss:theme-dark", function() {
return gulp.src(paths.output + "css/main.css") // return scssPipeline({
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) // input: paths.app + "styles/main-theme-dark.scss",
.pipe(gulp.dest(paths.output + "css/")); // output: paths.output + "css/"
}); // });
// });
gulp.task("cssmin", function() { gulp.task("scss:all", [ // "scss:theme-dark",
"scss:theme-light"]);
gulp.task("dist:cssmin", function() {
return gulp.src(paths.output + "css/main.css") return gulp.src(paths.output + "css/main.css")
.pipe(cssmin()) .pipe(cssmin())
.pipe(gulp.dest(paths.output + "css/")); .pipe(gulp.dest(paths.output + "css/"));
@ -40,7 +62,7 @@ gulp.task("template", function() {
var tmpl = mustache({ var tmpl = mustache({
jsfile: "/js/main.js?v=" + ts, jsfile: "/js/main.js?v=" + ts,
cssfile: "/css/main.css?v=" + ts cssfile: "/css/main.css?v=" + ts
}) });
return gulp.src(paths.app + "index.mustache") return gulp.src(paths.app + "index.mustache")
.pipe(tmpl) .pipe(tmpl)
@ -48,15 +70,11 @@ gulp.task("template", function() {
.pipe(gulp.dest(paths.output)); .pipe(gulp.dest(paths.output));
}); });
gulp.task("styles-dev", function(next) { gulp.task("dist:scss", function(next) {
runseq("scss", "autoprefixer", next); runseq("scss:all", "dist:cssmin", next);
}); });
gulp.task("styles-dist", function(next) { gulp.task("dist:clean", function(next) {
runseq("scss", "autoprefixer", next);
});
gulp.task("clean-dist", function(next) {
rimraf(paths.dist, next); rimraf(paths.dist, next);
}); });
@ -68,17 +86,17 @@ gulp.task("clean", function(next) {
}); });
}); });
gulp.task("copy", function() { gulp.task("dist:copy", function() {
return gulp.src(paths.output + "/**/*.*") return gulp.src(paths.output + "/**/*.*")
.pipe(gulp.dest(paths.dist)); .pipe(gulp.dest(paths.dist));
}); });
// Default // Default
gulp.task("dist", function(next) { gulp.task("dist", function(next) {
runseq("styles-dist", "cssmin", "template", "clean-dist", "copy", next); runseq("template", "dist:scss", "dist:clean", "dist:copy", next);
}); });
// Watch // Watch
gulp.task("default", ["styles-dev", "template"], function () { gulp.task("default", ["scss:all", "template"], function () {
gulp.watch(paths.scss, ["styles-dev"]); gulp.watch(paths.scss, ["scss:all"]);
}); });

30
npm-shrinkwrap.json generated
View file

@ -174,6 +174,11 @@
"from": "browserslist@>=1.1.3 <1.2.0", "from": "browserslist@>=1.1.3 <1.2.0",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-1.1.3.tgz" "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-1.1.3.tgz"
}, },
"buffers": {
"version": "0.1.1",
"from": "buffers@>=0.1.1 <0.2.0",
"resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz"
},
"builtin-modules": { "builtin-modules": {
"version": "1.1.1", "version": "1.1.1",
"from": "builtin-modules@>=1.0.0 <2.0.0", "from": "builtin-modules@>=1.0.0 <2.0.0",
@ -210,9 +215,9 @@
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.4.2.tgz" "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.4.2.tgz"
}, },
"clean-css": { "clean-css": {
"version": "3.4.9", "version": "3.4.11",
"from": "clean-css@>=3.1.9 <4.0.0", "from": "clean-css@>=3.1.9 <4.0.0",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.9.tgz", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.11.tgz",
"dependencies": { "dependencies": {
"commander": { "commander": {
"version": "2.8.1", "version": "2.8.1",
@ -621,9 +626,14 @@
"from": "gulp-autoprefixer@3.1.0", "from": "gulp-autoprefixer@3.1.0",
"resolved": "https://registry.npmjs.org/gulp-autoprefixer/-/gulp-autoprefixer-3.1.0.tgz" "resolved": "https://registry.npmjs.org/gulp-autoprefixer/-/gulp-autoprefixer-3.1.0.tgz"
}, },
"gulp-css-base64": {
"version": "1.3.4",
"from": "gulp-css-base64@latest",
"resolved": "https://registry.npmjs.org/gulp-css-base64/-/gulp-css-base64-1.3.4.tgz"
},
"gulp-cssmin": { "gulp-cssmin": {
"version": "0.1.7", "version": "0.1.7",
"from": "gulp-cssmin@latest", "from": "gulp-cssmin@0.1.7",
"resolved": "https://registry.npmjs.org/gulp-cssmin/-/gulp-cssmin-0.1.7.tgz", "resolved": "https://registry.npmjs.org/gulp-cssmin/-/gulp-cssmin-0.1.7.tgz",
"dependencies": { "dependencies": {
"ansi-regex": { "ansi-regex": {
@ -1094,8 +1104,7 @@
"dependencies": { "dependencies": {
"lodash.keys": { "lodash.keys": {
"version": "2.4.1", "version": "2.4.1",
"from": "lodash.keys@>=2.4.1 <2.5.0", "from": "lodash.keys@>=2.4.1 <2.5.0"
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz"
} }
} }
}, },
@ -1116,8 +1125,7 @@
"dependencies": { "dependencies": {
"lodash.keys": { "lodash.keys": {
"version": "2.4.1", "version": "2.4.1",
"from": "lodash.keys@>=2.4.1 <2.5.0", "from": "lodash.keys@>=2.4.1 <2.5.0"
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz"
} }
} }
}, },
@ -1193,8 +1201,7 @@
"dependencies": { "dependencies": {
"lodash.keys": { "lodash.keys": {
"version": "2.4.1", "version": "2.4.1",
"from": "lodash.keys@>=2.4.1 <2.5.0", "from": "lodash.keys@>=2.4.1 <2.5.0"
"resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz"
} }
} }
}, },
@ -1235,6 +1242,11 @@
"from": "micromatch@>=2.1.5 <3.0.0", "from": "micromatch@>=2.1.5 <3.0.0",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.7.tgz" "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.7.tgz"
}, },
"mime": {
"version": "1.3.4",
"from": "mime@>=1.3.4 <2.0.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz"
},
"mime-db": { "mime-db": {
"version": "1.22.0", "version": "1.22.0",
"from": "mime-db@>=1.22.0 <1.23.0", "from": "mime-db@>=1.22.0 <1.23.0",

View file

@ -18,6 +18,7 @@
"devDependencies": { "devDependencies": {
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-autoprefixer": "3.1.0", "gulp-autoprefixer": "3.1.0",
"gulp-css-base64": "1.3.4",
"gulp-cssmin": "0.1.7", "gulp-cssmin": "0.1.7",
"gulp-mustache": "2.2.0", "gulp-mustache": "2.2.0",
"gulp-plumber": "1.1.0", "gulp-plumber": "1.1.0",

View file

@ -5,7 +5,7 @@
@import 'dependencies/colors'; @import 'dependencies/colors';
@import 'dependencies/uxbox-light'; @import 'dependencies/uxbox-light';
//@import 'dependencies/uxbox-dark'; /* @import 'dependencies/uxbox-dark'; */
@import 'dependencies/helpers'; @import 'dependencies/helpers';
@import 'dependencies/mixin'; @import 'dependencies/mixin';
@import 'dependencies/fonts'; @import 'dependencies/fonts';