-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·115 lines (99 loc) · 2.55 KB
/
gulpfile.js
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
require('es6-promise').polyfill();
var webpack = require("webpack");
var webpackStream = require("webpack-stream");
var webpackConfig = require("./webpack.config");
var runSequence = require('run-sequence');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var src_paths = {
sass: ['src/scss/*.scss'],
script: ['src/js/*.js'],
};
var dest_paths = {
style: 'static/css/',
script: 'static/js/',
browserSync: ''
};
gulp.task('lint:sass', function() {
return gulp.src(src_paths.sass)
.pipe($.plumber({
errorHandler: function(err) {
console.log(err.messageFormatted);
this.emit('end');
}
}))
.pipe($.stylelint({
config: {
ignoreFiles: "src/scss/_normalize.scss",
extends: [
"stylelint-config-recommended",
"stylelint-scss",
"stylelint-config-recommended-scss"
],
rules: {
"block-no-empty": null,
"no-descending-specificity": null
}
},
reporters: [
{
formatter: 'string',
console: true
}
]
}));
});
gulp.task('sass:style', function() {
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({
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() {
return gulp.src(src_paths.script)
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('webpack', function() {
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
);
});
gulp.task('watch', function() {
gulp.watch([src_paths.sass, src_paths.script], ['default']);
});