|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
'use strict'
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
//----------------
|
|
|
|
|
//------------------------
|
|
|
|
|
//:: Initiate npm-modules
|
|
|
|
|
|
|
|
|
|
const gulp = require('gulp'),
|
|
|
|
|
sass = require('gulp-sass'),
|
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
@ -15,8 +16,10 @@ const gulp = require('gulp'),
|
|
|
|
|
merge2 = require('merge2'),
|
|
|
|
|
rimraf = require('rimraf');
|
|
|
|
|
|
|
|
|
|
//----------------
|
|
|
|
|
//:: configs
|
|
|
|
|
|
|
|
|
|
//------------------------
|
|
|
|
|
//:: Config parameter
|
|
|
|
|
|
|
|
|
|
var Config = {
|
|
|
|
|
inputDir: '_source/',
|
|
|
|
|
outputDir: '_dist/'
|
|
|
|
@ -30,22 +33,18 @@ var SassConfig = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var postcss_plugins = [
|
|
|
|
|
cssnano,
|
|
|
|
|
autoprefixer
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
//----------------
|
|
|
|
|
//------------------------
|
|
|
|
|
//:: Tasks
|
|
|
|
|
|
|
|
|
|
// compile scss
|
|
|
|
|
function scss() {
|
|
|
|
|
function scss_addons() {
|
|
|
|
|
var onError = function(err) {
|
|
|
|
|
notify.onError({
|
|
|
|
|
title: 'gulp',
|
|
|
|
|
subtitle: 'Error!',
|
|
|
|
|
message: '❌ <%= error.message %>',
|
|
|
|
|
sound: 'Submarine'
|
|
|
|
|
title: 'scss_addons',
|
|
|
|
|
subtitle: 'Error!',
|
|
|
|
|
message: '❌ <%= error.message %>',
|
|
|
|
|
sound: 'Submarine'
|
|
|
|
|
})(err);
|
|
|
|
|
this.emit('end');
|
|
|
|
|
};
|
|
|
|
@ -55,22 +54,44 @@ function scss() {
|
|
|
|
|
'node_modules/sanitize.css/sanitize.css'
|
|
|
|
|
]))
|
|
|
|
|
.pipe(concat('addons.css'))
|
|
|
|
|
.pipe(postcss([autoprefixer()]))
|
|
|
|
|
.pipe(gulp.dest(SassConfig.outputDir))
|
|
|
|
|
.pipe(postcss(postcss_plugins))
|
|
|
|
|
.pipe(postcss([cssnano()]))
|
|
|
|
|
.pipe(rename({suffix: '.min'}))
|
|
|
|
|
.pipe(gulp.dest(SassConfig.outputDir)),
|
|
|
|
|
.pipe(gulp.dest(SassConfig.outputDir))
|
|
|
|
|
.pipe(livereload())
|
|
|
|
|
.pipe(notify({
|
|
|
|
|
title: 'scss_addons',
|
|
|
|
|
subtitle: 'Success!',
|
|
|
|
|
message: '✅ SCSS compiled',
|
|
|
|
|
timeout: '2'
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gulp.src(SassConfig.inputDir + '*.scss')
|
|
|
|
|
function scss_main() {
|
|
|
|
|
var onError = function(err) {
|
|
|
|
|
notify.onError({
|
|
|
|
|
title: 'scss_main',
|
|
|
|
|
subtitle: 'Error!',
|
|
|
|
|
message: '❌ <%= error.message %>',
|
|
|
|
|
sound: 'Submarine'
|
|
|
|
|
})(err);
|
|
|
|
|
this.emit('end');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return gulp
|
|
|
|
|
.src(SassConfig.inputDir + '*.scss')
|
|
|
|
|
.pipe(concat('styles.css'))
|
|
|
|
|
.pipe(plumber({errorHandler: onError}))
|
|
|
|
|
.pipe(postcss(postcss_plugins))
|
|
|
|
|
.pipe(sass(SassConfig.options).on('error', sass.logError))
|
|
|
|
|
.pipe(postcss([autoprefixer()]))
|
|
|
|
|
.pipe(gulp.dest(SassConfig.outputDir))
|
|
|
|
|
.pipe(postcss([cssnano()]))
|
|
|
|
|
.pipe(rename({suffix: '.min'}))
|
|
|
|
|
.pipe(gulp.dest(SassConfig.outputDir))
|
|
|
|
|
.pipe(livereload())
|
|
|
|
|
.pipe(notify({
|
|
|
|
|
title: 'gulp',
|
|
|
|
|
title: 'scss_main',
|
|
|
|
|
subtitle: 'Success!',
|
|
|
|
|
message: '✅ SCSS compiled',
|
|
|
|
|
timeout: '2'
|
|
|
|
@ -79,16 +100,16 @@ function scss() {
|
|
|
|
|
|
|
|
|
|
// Copy those other files
|
|
|
|
|
function copy(done) {
|
|
|
|
|
gulp.src([Config.inputDir + '*.*'])
|
|
|
|
|
gulp.src([Config.inputDir + '**/*.*'])
|
|
|
|
|
.pipe(gulp.dest(Config.outputDir))
|
|
|
|
|
.pipe(livereload())
|
|
|
|
|
done();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// watch for changes
|
|
|
|
|
// Watch for changes
|
|
|
|
|
function watch() {
|
|
|
|
|
livereload.listen();
|
|
|
|
|
gulp.watch(SassConfig.inputDir + '*.scss', scss);
|
|
|
|
|
gulp.watch(SassConfig.inputDir + '*.scss', scss_main);
|
|
|
|
|
gulp.watch(Config.inputDir + '*.html', copy);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -97,14 +118,16 @@ function cleanup(cb) {
|
|
|
|
|
return rimraf(Config.outputDir + '*', cb)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//----------------
|
|
|
|
|
//:: Export tasks
|
|
|
|
|
|
|
|
|
|
//------------------------
|
|
|
|
|
//:: Define tasks
|
|
|
|
|
|
|
|
|
|
// complex tasks
|
|
|
|
|
const build = gulp.series(cleanup, gulp.parallel(copy, scss));
|
|
|
|
|
const build = gulp.series(cleanup, gulp.parallel(copy, scss_addons, scss_main));
|
|
|
|
|
|
|
|
|
|
// export tasks
|
|
|
|
|
exports.scss = scss;
|
|
|
|
|
exports.scss_main = scss_main;
|
|
|
|
|
exports.scss_addons = scss_addons;
|
|
|
|
|
exports.copy = copy;
|
|
|
|
|
exports.watch = watch;
|
|
|
|
|
exports.cleanup = cleanup;
|
|
|
|
|