-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
51 lines (42 loc) · 1.47 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const sass = require('gulp-sass');
const pug = require('gulp-pug');
const plumber = require('gulp-plumber');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const rename = require("gulp-rename");
const filter = require('gulp-filter');
const uglify = require('gulp-uglify');
const babelOpts = {
presets: ['es2015'],
compact: false
};
gulp.task('webHtml', () => {
const pugOpts = {
data: {},
pretty: false,
compileDebug: true
};
gulp.src('./src/html/**/*.pug').pipe(filter(file => !/\/_/.test(file.path) && !/^_/.test(file.relative))).pipe(plumber()).pipe(pug(pugOpts)).pipe(gulp.dest('./dist/'))
});
gulp.task('webCss', () => {
const sassOpts = {
outputStyle: 'nested'
};
gulp.src(`./src/css/main.scss`).pipe(sass(sassOpts).on('error', sass.logError)).pipe(autoprefixer({
browsers: [
'ff >= 4', 'Chrome >= 19', 'ie >= 9'
],
cascade: false
})).pipe(cleanCSS()).pipe(gulp.dest('./dist/css/'))
});
gulp.task('webJs', () => {
gulp.src('./src/js/**/*.es6').pipe(plumber()).pipe(babel(babelOpts)).pipe(uglify()).pipe(gulp.dest('./dist/js/'))
});
gulp.task('build', ['webJs', 'webCss', 'webHtml']);
gulp.task('default', () => {
gulp.watch('./src/css/**/*.scss', ['webCss']);
gulp.watch('./src/html/**/*.pug', ['webHtml']);
gulp.watch('./src/js/**/*.es6', ['webJs']);
});