From 6c5e40831c9b0a5f251702aa200f5c431f222472 Mon Sep 17 00:00:00 2001 From: Iqbal Date: Mon, 11 Feb 2019 10:15:55 +0700 Subject: [PATCH 1/3] Update for GULP --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 7cdd154..6bc92ec 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,8 @@ "summernote": "^0.8.11", "sweetalert": "^2.1.2", "weathericons": "^2.1.0" + }, + "devDependencies": { + "gulp": "^4.0.0" } } From 306495b6e8f2afdf3da6280b83bcb9d20a166b3e Mon Sep 17 00:00:00 2001 From: Iqbal Date: Mon, 11 Feb 2019 10:28:13 +0700 Subject: [PATCH 2/3] Added gulp --- gulpfile.js | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 gulpfile.js diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..0caab43 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,125 @@ +// Gulp file config by iqbal + +const {src, dest, watch, parallel} = require('gulp'); +const notify = require('gulp-notify'); +const browserSync = require('browser-sync').create(); +const sass = require('gulp-sass'); +const concat = require('gulp-concat'); +const plumber = require('gulp-plumber'); +const rename = require('gulp-rename'); +const postcss = require('gulp-postcss'); +const autoprefixer = require('autoprefixer'); +const cssnano = require('cssnano'); +const uglify = require('gulp-uglify'); +const imagemin = require('gulp-imagemin'); +const imageminMozjpeg = require('imagemin-mozjpeg'); +//dir +var cssDir = './assets/css'; +var jsDir = './assets/js'; +var sassDir = './assets/sass/*.scss'; +var imgDir = './assets/img/*'; + +//css +var cssFileOne = 'path'; +var cssFileTwo = 'path'; +var cssFileThree = 'path'; + +//js +var jsFileOne = 'path'; +var jsFileTwo = 'path'; +var jsFileThree = 'path'; + +// moving js +function js(){ + return src([jsFileOne, jsFileTwo, jsFileThree]) + .pipe(plumber()) + .pipe(concat('plugin.min.js')) + .pipe(uglify()) + .pipe(dest(jsDir)) + .pipe(notify({ + message: 'File <%= file.relative %> wis dadi' + })); +} + +// moving css +function css(){ + return src([cssFileOne,cssFileTwo,cssFileThree,]) + .pipe(plumber()) + .pipe(concat('plugin.min.css')) + .pipe(postcss([autoprefixer(), cssnano()])) + .pipe(dest(cssDir)) + .pipe(notify({ + message: 'File <%= file.relative %> wis dadi' + })); +} + +//make structural folder +function folder(){ + return src('*.*', {read: false}) + .pipe(dest('./sandbox/_test')) + .pipe(dest('./assets')) + .pipe(dest('./assets/sass')) + .pipe(dest('./assets/css')) + .pipe(dest('./assets/js')) + .pipe(dest('./assets/img')) +} + +//minify compile +function minify(){ + return src(sassDir) + .pipe(plumber()) + .pipe(sass({ + errorLogToConsole: true + })) + .on('error', console.error.bind( console )) + .pipe(rename({ + suffix: '.min' + })) + .pipe(postcss([autoprefixer(), cssnano()])) + .pipe(dest(cssDir)) + .pipe(notify({ + message: 'Minify <%= file.relative %> berhasil bos' + })); +} + + +//minfy image +function image(){ + return src(imgDir) + .pipe(plumber()) + .pipe(imagemin([ + imageminMozjpeg({quality: 80}) + ])) + .pipe(dest(imgDir)) + .pipe(plumber.stop()) +} + +function watching (){ + browserSync.init({ + server:{ + baseDir: "./" + }, + port: 8080 + }); + watch('./assets/sass/*.scss',minify).on('change',browserSync.reload); + watch("*.html").on('change',browserSync.reload); +} + +function watchcss(){ + watch('./assets/sass/*.scss',minify); +} + +//create folder first +exports.folder = folder; +//then update source +exports.update = parallel(js, css); +//updating JS SOURCE ONLY +exports.js = js; +//updating CSS SOURCE ONLY +exports.css = css; +//minify IMG SOURCE +exports.image = image; +//Run this command for styling OPs +exports.minify = minify; +//Run this command for dev. +exports.default = watching; \ No newline at end of file From b80ddfae012f0f93a7e0325d5d142bb2db2089eb Mon Sep 17 00:00:00 2001 From: Iqbal Date: Mon, 11 Feb 2019 10:29:09 +0700 Subject: [PATCH 3/3] Update package.json for gulp --- package.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6bc92ec..165f320 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,17 @@ "weathericons": "^2.1.0" }, "devDependencies": { - "gulp": "^4.0.0" + "autoprefixer": "^9.4.7", + "browser-sync": "^2.26.3", + "cssnano": "^4.1.8", + "gulp-concat": "^2.6.1", + "gulp-imagemin": "^5.0.3", + "gulp-notify": "^3.2.0", + "gulp-plumber": "^1.2.1", + "gulp-postcss": "^8.0.0", + "gulp-rename": "^1.4.0", + "gulp-sass": "^4.0.2", + "gulp-uglify": "^3.0.1", + "imagemin-mozjpeg": "^8.0.0" } }