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
| var gulp = require("gulp"), mkdir = require("mkdirp");
var includeFile = require("gulp-file-include"), connect = require("gulp-connect"), sass = require("gulp-sass"), postcss = require("gulp-postcss"), autoprefixer = require("autoprefixer"), cssnext = require("cssnext"), precss = require("precss");
var __srcPath = "./src/"; var __buildPath = "./build/";
var __dev = { port: 8002,
src: { html: __srcPath + "html/", style: __srcPath + "styles/", js: __srcPath + "javascript/", images: __srcPath + "images/", img: __srcPath + "img/" },
build: { html: __buildPath, style: __buildPath + "public/styles/", js: __buildPath + "public/javascript/", images: __buildPath + "public/images/", img: __buildPath + "public/img/" } };
gulp.task("create", function() { mkdir.sync(__dev.src.html); mkdir.sync(__dev.src.js); mkdir.sync(__dev.src.style); mkdir.sync(__dev.src.images); mkdir.sync(__dev.src.img); });
gulp.task("html", function() { gulp .src(__dev.src.html + "*.html") .pipe( includeFile({ indent: true }) ) .pipe(gulp.dest(__dev.build.html)); });
gulp.task("style", function() { var processors = [autoprefixer({ browsers: [">1%", "last 12 version"] }), cssnext, precss];
gulp .src(__dev.src.style + "*.scss") .pipe( sass({
outputStyle: "compressed" }).on("error", sass.logError) ) .pipe(postcss(processors)) .pipe(gulp.dest(__dev.build.style)); });
gulp.task("img", function() { gulp.src(__dev.src.img + "*.*").pipe(gulp.dest(__dev.build.img)); });
gulp.task("images", function() { gulp.src(__dev.src.images + "*.*").pipe(gulp.dest(__dev.build.images)); });
gulp.task("javascript", function(callback) { gulp.src(__dev.src.js + "**/*.*").pipe(gulp.dest(__dev.build.js)); });
gulp.task("fonts", function(callback) { gulp.src("./src/fonts/" + "*.*").pipe(gulp.dest("./build/public/fonts")); });
gulp.task("connect", function() { connect.server({ root: __dev.build.html, port: __dev.port, livereload: true
}); });
gulp.task("reload", function() { gulp.src(__dev.build.html + "*.html").pipe(connect.reload()); });
gulp.task("watch", function() { gulp.watch(__dev.src.html + "**/*.html", ["html"]); gulp.watch(__dev.src.style + "**/*.scss", ["style"]); gulp.watch(__dev.src.js + "**/*.js", ["javascript"]); gulp.watch(__dev.build.style + "*.css", ["reload"]); gulp.watch(__dev.build.js + "*.js", ["reload"]); gulp.watch(__dev.build.html + "*.html", ["reload"]); });
gulp.task("default", ["html", "style", "img", "images", "javascript", "fonts", "connect", "watch"]);
|
Comments