From 2f6c632476fad2dbd5c40cfaf3dd70d5fbc57f15 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 3 Apr 2016 13:19:11 +0300 Subject: [PATCH] Minor improvements on gulpfile. --- gulpfile.js | 64 ++++++++++++++++++++++++-------------- npm-shrinkwrap.json | 30 ++++++++++++------ package.json | 1 + resources/styles/main.scss | 2 +- 4 files changed, 64 insertions(+), 33 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e46178cdd..9cf5f5dc1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,20 +16,42 @@ paths.dist = "./dist/"; paths.target = "./target/"; paths.scss = paths.app + "styles/**/*.scss"; -gulp.task("scss", function() { - return gulp.src(paths.app + "styles/main.scss") - .pipe(plumber()) - .pipe(scss({style: "expanded"})) - .pipe(gulp.dest(paths.output + "css/")); +function makeAutoprefixer() { + 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(scss({style: "expanded"})) + .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() { - return gulp.src(paths.output + "css/main.css") - .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) - .pipe(gulp.dest(paths.output + "css/")); -}); +// gulp.task("scss:theme-dark", function() { +// return scssPipeline({ +// input: paths.app + "styles/main-theme-dark.scss", +// 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") .pipe(cssmin()) .pipe(gulp.dest(paths.output + "css/")); @@ -40,7 +62,7 @@ gulp.task("template", function() { var tmpl = mustache({ jsfile: "/js/main.js?v=" + ts, cssfile: "/css/main.css?v=" + ts - }) + }); return gulp.src(paths.app + "index.mustache") .pipe(tmpl) @@ -48,15 +70,11 @@ gulp.task("template", function() { .pipe(gulp.dest(paths.output)); }); -gulp.task("styles-dev", function(next) { - runseq("scss", "autoprefixer", next); +gulp.task("dist:scss", function(next) { + runseq("scss:all", "dist:cssmin", next); }); -gulp.task("styles-dist", function(next) { - runseq("scss", "autoprefixer", next); -}); - -gulp.task("clean-dist", function(next) { +gulp.task("dist:clean", function(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 + "/**/*.*") .pipe(gulp.dest(paths.dist)); }); // Default gulp.task("dist", function(next) { - runseq("styles-dist", "cssmin", "template", "clean-dist", "copy", next); + runseq("template", "dist:scss", "dist:clean", "dist:copy", next); }); // Watch -gulp.task("default", ["styles-dev", "template"], function () { - gulp.watch(paths.scss, ["styles-dev"]); +gulp.task("default", ["scss:all", "template"], function () { + gulp.watch(paths.scss, ["scss:all"]); }); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 3b900c920..f6da4e8f5 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -174,6 +174,11 @@ "from": "browserslist@>=1.1.3 <1.2.0", "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": { "version": "1.1.1", "from": "builtin-modules@>=1.0.0 <2.0.0", @@ -210,9 +215,9 @@ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.4.2.tgz" }, "clean-css": { - "version": "3.4.9", + "version": "3.4.11", "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": { "commander": { "version": "2.8.1", @@ -621,9 +626,14 @@ "from": "gulp-autoprefixer@3.1.0", "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": { "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", "dependencies": { "ansi-regex": { @@ -1094,8 +1104,7 @@ "dependencies": { "lodash.keys": { "version": "2.4.1", - "from": "lodash.keys@>=2.4.1 <2.5.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz" + "from": "lodash.keys@>=2.4.1 <2.5.0" } } }, @@ -1116,8 +1125,7 @@ "dependencies": { "lodash.keys": { "version": "2.4.1", - "from": "lodash.keys@>=2.4.1 <2.5.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz" + "from": "lodash.keys@>=2.4.1 <2.5.0" } } }, @@ -1193,8 +1201,7 @@ "dependencies": { "lodash.keys": { "version": "2.4.1", - "from": "lodash.keys@>=2.4.1 <2.5.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz" + "from": "lodash.keys@>=2.4.1 <2.5.0" } } }, @@ -1235,6 +1242,11 @@ "from": "micromatch@>=2.1.5 <3.0.0", "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": { "version": "1.22.0", "from": "mime-db@>=1.22.0 <1.23.0", diff --git a/package.json b/package.json index fdcf9649a..e0a0f18ca 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "devDependencies": { "gulp": "3.9.1", "gulp-autoprefixer": "3.1.0", + "gulp-css-base64": "1.3.4", "gulp-cssmin": "0.1.7", "gulp-mustache": "2.2.0", "gulp-plumber": "1.1.0", diff --git a/resources/styles/main.scss b/resources/styles/main.scss index 110aa2758..667e1a414 100644 --- a/resources/styles/main.scss +++ b/resources/styles/main.scss @@ -5,7 +5,7 @@ @import 'dependencies/colors'; @import 'dependencies/uxbox-light'; -//@import 'dependencies/uxbox-dark'; +/* @import 'dependencies/uxbox-dark'; */ @import 'dependencies/helpers'; @import 'dependencies/mixin'; @import 'dependencies/fonts';