Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gulpfile.js - github.com/thingsym/hugo-theme-techdoc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0e3f89689586f81ca95ca6c96779d779d5a9db23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'use strict';

const gulp = require('gulp');
const $ = require('gulp-load-plugins')();

require('es6-promise').polyfill();

const webpack = require("webpack");
const webpackStream = require("webpack-stream");
const webpackConfig = require("./webpack.config");

const src_paths = {
  sass: ['src/scss/*.scss'],
  script: ['src/js/*.js'],
};

const dest_paths = {
  style: 'static/css/',
  script: 'static/js/',
};

function lint_sass() {
  return gulp.src(src_paths.sass)
    .pipe($.plumber({
      errorHandler: function(err) {
        console.log(err.messageFormatted);
        this.emit('end');
      }
    }))
    .pipe($.stylelint({
      config: {
        extends: [
          "stylelint-config-recommended",
          "stylelint-scss",
          "stylelint-config-recommended-scss"
        ],
        rules: {
          "block-no-empty": null,
          "no-descending-specificity": null
        }
      },
      reporters: [{
        formatter: 'string',
        console: true
      }]
    }));
};

function style_sass() {
  return gulp.src(src_paths.sass)
    .pipe($.plumber({
      errorHandler: function(err) {
        console.log(err.messageFormatted);
        this.emit('end');
      }
    }))
    .pipe($.sass({
      outputStyle: 'expanded'
    }).on( 'error', $.sass.logError ))
    .pipe($.autoprefixer({
        cascade: false
    }))
    .pipe(gulp.dest(dest_paths.style))
    .pipe($.cssnano())
    .pipe($.rename({ suffix: '.min' }))
    .pipe(gulp.dest(dest_paths.style));
}

function lint_eslint() {
  return gulp.src(src_paths.script)
    .pipe($.eslint.format())
    .pipe($.eslint.failAfterError());
};

function script() {
  return webpackStream(webpackConfig, webpack)
    .on('error', function (e) {
      this.emit('end');
    })
    .pipe(gulp.dest("dist"));
};

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));
}

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));