-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (49 loc) · 1.5 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
var gulp = require('gulp'),
browserSync = require('browser-sync').create(),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
babel = require("gulp-babel"),
uglify = require('gulp-uglify'),
plumber = require("gulp-plumber"),
cleanCSS = require('gulp-clean-css');
gulp.task('server', ['sass', 'babel'], function() {
browserSync.init({
server: "./",
open: false
});
gulp.watch("./*.html").on('change', browserSync.reload);
gulp.watch("./*.s+(a|c)ss", ['sass']);
gulp.watch("./*.js", ['babel']);
});
gulp.task('sass', function() {
return gulp.src("./main.sass")
.pipe(sass({
errLogToConsole: true,
outputStyle: 'expanded',
includePaths: require('node-normalize-scss').includePaths
}).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(gulp.dest("./dist"))
.pipe(browserSync.stream());
});
gulp.task('babel', function () {
return gulp.src("./main.js")
.pipe(plumber())
.pipe(babel({
"presets": ["babel-preset-env"].map(require.resolve)
}))
.pipe(gulp.dest("./dist"))
.pipe(browserSync.stream());
});
gulp.task('miniJS', function () {
return gulp.src("dist/main.js")
.pipe(uglify())
.pipe(gulp.dest("./dist"));
});
gulp.task('miniCSS', function () {
return gulp.src("dist/main.css")
.pipe(cleanCSS())
.pipe(gulp.dest('./dist'));
});
gulp.task('mini', ['miniJS', "miniCSS"]);
gulp.task('default', ['server']);