Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <binding ProjectOpened='watch' />
- "use strict";
- var gulp = require('gulp'),
- rimraf = require('rimraf'),
- debug = require('gulp-debug'),
- watch = require('gulp-watch'),
- sass = require('gulp-sass'),
- cssmin = require('gulp-cssmin'),
- imagemin = require('gulp-imagemin'),
- autoprefixer = require('gulp-autoprefixer'),
- uglify = require('gulp-uglify');
- var paths = {
- webroot: "wwwroot/",
- assets: "Assets/"
- };
- paths.js = paths.assets + "js/**/*.js";
- paths.css = paths.assets + "css/**/*.scss";
- paths.img = paths.assets + "images/**/*";
- paths.jsDest = paths.webroot + "js/";
- paths.cssDest = paths.webroot + "css/";
- paths.imgDest = paths.webroot + "images/";
- paths.jsMin = paths.webroot + "js/**/*.min.js";
- paths.cssMin = paths.webroot + "css/**/*.min.css";
- paths.imgMin = paths.webroot + "images/**/*";
- gulp.task("clean:js", function (callback) {
- rimraf(paths.jsMin, callback);
- });
- gulp.task("clean:css", function (callback) {
- rimraf(paths.cssMin, callback);
- });
- gulp.task("clean:img", function (callback) {
- rimraf(paths.imgMin, callback);
- });
- gulp.task("clean", ["clean:js", "clean:css", "clean:img"]);
- gulp.task("min:js", function () {
- return gulp.src(paths.js, { base: "./Assets/js/" })
- .pipe(debug())
- .pipe(uglify())
- .on("error", (e) => {
- console.error("There was a problem compiling the js files,");
- console.error(e);
- })
- .pipe(gulp.dest(paths.jsDest));
- });
- gulp.task("min:css", function () {
- return gulp.src(paths.css, { base: "./Assets/css/" })
- .pipe(debug())
- .pipe(sass())
- .on("error", (e) => {
- console.error("There was a problem compiling the sass files");
- console.error(e);
- })
- .pipe(cssmin())
- .pipe(autoprefixer({
- browsers: ['last 2 versions'],
- cascade: false
- }))
- .pipe(gulp.dest(paths.cssDest));
- });
- gulp.task("min:img", function () {
- return gulp.src(paths.img, { base: "./Assets/images/" })
- .pipe(debug())
- .pipe(imagemin())
- .on("error", (e) => {
- console.error("There was a problem minifying the images");
- console.error(e);
- })
- .pipe(gulp.dest(paths.imgDest));
- });
- gulp.task("min", ["min:js", "min:css", "min:img"]);
- gulp.task("watch", function () {
- gulp.watch(paths.js, ["min:js"]);
- gulp.watch(paths.css, ["min:css"]);
- gulp.watch(paths.img, ["min:img"]);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement