reactivated js gulp task

This commit is contained in:
Stephan Hagedorn 2018-08-16 10:33:04 +02:00
parent 273cef9234
commit 4708896f79

View file

@ -17,38 +17,39 @@ var build_folder = {
} }
// Load plugins // Load plugins
var fs = require('fs'); const fs = require('fs');
const gulp = require('gulp'), const gulp = require('gulp');
// rename = require('gulp-rename'), // const rename = require('gulp-rename');
del = require('del'); const del = require('del');
gulpif = require('gulp-if'); const gulpif = require('gulp-if');
sequencer = require('run-sequence'); const sequencer = require('run-sequence');
// concat = require('gulp-concat'), const sourcemap = require('gulp-sourcemaps');
// pump = require('pump'), const prefix = require('gulp-autoprefixer');
sourcemap = require('gulp-sourcemaps'), const sass = require('gulp-sass');
prefix = require('gulp-autoprefixer'), // const rubysass = require('gulp-ruby-sass');
sass = require('gulp-sass'), const nunjucks = require('gulp-nunjucks-render');
// rubysass = require('gulp-ruby-sass'), // const cssnano = require('gulp-cssnano');
nunjucks = require('gulp-nunjucks-render'); const jshint = require('gulp-jshint');
// cssnano = require('gulp-cssnano'), const jscs = require('gulp-jscs');
jshint = require('gulp-jshint'), // const useref = require('gulp-useref');
jscs = require('gulp-jscs'), const sasslint = require('gulp-sass-lint');
// useref = require('gulp-useref'), // const imagemin = require('gulp-imagemin');
sasslint = require('gulp-sass-lint'), const spritesmith = require('gulp.spritesmith');
// uglifyjs = require('uglify-es'), // const changed = require('gulp-changed');
// composer = require('gulp-uglify/composer'), // const newer = require('gulp-newer');
// imagemin = require('gulp-imagemin'), const plumber = require('gulp-plumber');
spritesmith = require('gulp.spritesmith'), const notify = require('gulp-notify');
// cache = require('gulp-cached'), const data = require('gulp-data');
// remember = require('gulp-remember'), const browsersync = require('browser-sync').create();
// changed = require('gulp-changed'),
// newer = require('gulp-newer'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
data = require('gulp-data'),
browsersync = require('browser-sync').create();
// var minify = composer(uglifyjs, console); // only used for js task
const concat = require('gulp-concat');
const pump = require('pump');
const composer = require('gulp-uglify/composer');
const uglifyjs = require('uglify-es');
const minify = composer(uglifyjs, console);
const cache = require('gulp-cached');
const remember = require('gulp-remember');
@ -62,6 +63,7 @@ gulp.task('sass', function() {
includePaths: [source_folder.root+'/bower_components'] includePaths: [source_folder.root+'/bower_components']
})) }))
.pipe(prefix(['>= 4%', 'last 2 version'])) .pipe(prefix(['>= 4%', 'last 2 version']))
// .pipe(cssnano())
.pipe(sourcemap.write()) .pipe(sourcemap.write())
.pipe(gulp.dest(build_folder.styles)) .pipe(gulp.dest(build_folder.styles))
.pipe(browsersync.reload({ .pipe(browsersync.reload({
@ -70,6 +72,24 @@ gulp.task('sass', function() {
}); });
// and this is functionality
gulp.task('js', function(cb) {
pump([
gulp.src(source_folder.scripts),
cache('scripts'),
jshint('.jshintrc'),
jshint.reporter('default'),
sourcemap.init(),
minify(),
remember('scripts'),
concat('all.min.js'),
sourcemap.write(),
gulp.dest(build_folder.scripts),
browsersync.stream()
], cb);
});
// templating engine // templating engine
gulp.task('nunjucks', function() { gulp.task('nunjucks', function() {
return gulp.src('source/pages/**/*.+(html|njk)') return gulp.src('source/pages/**/*.+(html|njk)')
@ -150,7 +170,7 @@ gulp.task('clean:dev', function() {
// watch over changes and react // watch over changes and react
// split up into sub tasks // split up into sub tasks
gulp.task('watch-js', ['lint:js'], browsersync.reload); gulp.task('watch-js', ['lint:js', 'js'], browsersync.reload);
gulp.task('overwatch', function() { gulp.task('overwatch', function() {
gulp.watch('source/code/**/*.js', ['watch-js']) gulp.watch('source/code/**/*.js', ['watch-js'])
@ -168,7 +188,7 @@ gulp.task('default', function(callback) {
sequencer( sequencer(
'clean:dev', 'clean:dev',
['sprites', 'lint:js', 'lint:scss'], ['sprites', 'lint:js', 'lint:scss'],
['sass', 'nunjucks'], ['sass', 'js', 'nunjucks'],
['syncreload', 'overwatch'], ['syncreload', 'overwatch'],
callback callback
) )