-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (50 loc) · 1.48 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
const gulp = require('gulp');
// CSS
const sass = require('gulp-sass')(require('sass'));
const sourcemaps = require('gulp-sourcemaps');
const postcss = require('gulp-postcss');
// JS
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
gulp.task('html', function() {
return gulp.src('public/*.html')
.pipe(browserSync.stream());
});
gulp.task('css', function() {
return gulp.src('public/sass/main.sass')
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'expanded' }))
.pipe(postcss([
require('postcss-custom-properties')(),
require('autoprefixer')({ overrideBrowserslist: ['last 4 versions'] }),
require('cssnano')()
]))
.pipe(sourcemaps.write())
.pipe(gulp.dest('public/css'))
.pipe(browserSync.stream({ match: '**/*.css' }));
});
gulp.task('js', function() {
return gulp.src('public/js/main.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify())
.pipe(concat('main.min.js'))
.pipe(gulp.dest('public/js'))
.pipe(browserSync.stream());
});
gulp.task('default', gulp.series('html', 'css', function(done) {
browserSync.init({
server: {
baseDir: "public/"
},
port: 1337,
notify: false
});
gulp.watch('public/*.html', gulp.series('html'));
gulp.watch('public/sass/**', gulp.series('css'));
gulp.watch('public/js/main.js', gulp.series('js'));
done();
}));