diff options
author | thingsym <thingsym@gmail.com> | 2020-01-12 10:53:20 +0300 |
---|---|---|
committer | thingsym <thingsym@gmail.com> | 2020-01-12 10:53:20 +0300 |
commit | 59a1b1c8634f1ad4f780409e428e251153b9fdc4 (patch) | |
tree | d643505435149e26ab43cbc41c567d5a42d14230 /gulpfile.js | |
parent | f7aea9bdfe44216d3e35a1b69509b8b9f8444811 (diff) |
chore: gulp bump up version to 4.0
Diffstat (limited to 'gulpfile.js')
-rw-r--r-- | gulpfile.js | 79 |
1 files changed, 28 insertions, 51 deletions
diff --git a/gulpfile.js b/gulpfile.js index 3dfa4fa..0e3f896 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,32 +1,25 @@ 'use strict'; -var gulp = require('gulp'); -var $ = require('gulp-load-plugins')(); +const gulp = require('gulp'); +const $ = require('gulp-load-plugins')(); require('es6-promise').polyfill(); -var webpack = require("webpack"); -var webpackStream = require("webpack-stream"); -var webpackConfig = require("./webpack.config"); +const webpack = require("webpack"); +const webpackStream = require("webpack-stream"); +const webpackConfig = require("./webpack.config"); -var runSequence = require('run-sequence'); - -var browserSync = require('browser-sync').create(); -var reload = browserSync.reload; - -var src_paths = { +const src_paths = { sass: ['src/scss/*.scss'], script: ['src/js/*.js'], }; -var dest_paths = { +const dest_paths = { style: 'static/css/', script: 'static/js/', - browserSync: '' }; - -gulp.task('lint:sass', function() { +function lint_sass() { return gulp.src(src_paths.sass) .pipe($.plumber({ errorHandler: function(err) { @@ -36,7 +29,6 @@ gulp.task('lint:sass', function() { })) .pipe($.stylelint({ config: { - ignoreFiles: "src/scss/_normalize.scss", extends: [ "stylelint-config-recommended", "stylelint-scss", @@ -47,16 +39,14 @@ gulp.task('lint:sass', function() { "no-descending-specificity": null } }, - reporters: [ - { - formatter: 'string', - console: true - } - ] + reporters: [{ + formatter: 'string', + console: true + }] })); -}); +}; -gulp.task('sass:style', function() { +function style_sass() { return gulp.src(src_paths.sass) .pipe($.plumber({ errorHandler: function(err) { @@ -68,48 +58,35 @@ gulp.task('sass:style', function() { outputStyle: 'expanded' }).on( 'error', $.sass.logError )) .pipe($.autoprefixer({ - browsers: ['last 2 versions'], cascade: false })) .pipe(gulp.dest(dest_paths.style)) .pipe($.cssnano()) .pipe($.rename({ suffix: '.min' })) .pipe(gulp.dest(dest_paths.style)); -}); +} -gulp.task('lint:javascript', function() { - return gulp.src(dest_paths.script) - .pipe($.jshint()) - .pipe($.jshint.reporter('jshint-stylish')); -}); - -gulp.task('lint:eslint', function() { +function lint_eslint() { return gulp.src(src_paths.script) .pipe($.eslint.format()) .pipe($.eslint.failAfterError()); -}); +}; -gulp.task('webpack', function() { +function script() { return webpackStream(webpackConfig, webpack) .on('error', function (e) { this.emit('end'); }) .pipe(gulp.dest("dist")); -}); - -gulp.task('lint', ['lint:sass', 'lint:eslint', 'lint:javascript']); -gulp.task('sass', ['sass:style']); -gulp.task('script', ['webpack']); +}; -gulp.task('default', function(callback) { - runSequence( - 'lint', - 'sass', - 'script', - callback - ); -}); +function watch_files(done) { + gulp.watch(src_paths.sass).on('change', gulp.series(lint_sass, style_sass)); + gulp.watch(src_paths.script).on('change', gulp.series(lint_eslint, script)); +} -gulp.task('watch', function() { - gulp.watch([src_paths.sass, src_paths.script], ['default']); -}); +exports.lint = gulp.parallel(lint_sass, lint_eslint); +exports.style = style_sass; +exports.script = script; +exports.watch = watch_files; +exports.default = gulp.series(gulp.parallel(lint_sass, lint_eslint), gulp.parallel(style_sass, script)); |