-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
39 lines (34 loc) · 1.32 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
const gulp = require('gulp')
const autoprefixer = require('gulp-autoprefixer')
const babelify = require('babelify')
const browserify = require('browserify')
const buffer = require('vinyl-buffer')
const rename = require("gulp-rename")
const sass = require('gulp-sass');
const source = require('vinyl-source-stream')
const uglify = require('gulp-uglify')
gulp.task('build-sass', () => {
return gulp.src('src/scss/compile.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', (e) => console.log(e)))
.pipe(autoprefixer({ browsers: ['last 2 versions'], cascade: false }))
.pipe(rename({ basename: 'paggcerto-lightbox', extname: '.min.css' }))
.pipe(gulp.dest('dist'))
});
gulp.task('build-js', () => {
return browserify({
entries: ['src/js/bundle.js'],
fullPaths: false,
transform: [babelify.configure({ presets: ['env'] })]
})
.bundle().on('error', (e) => console.log(e))
.pipe(source('paggcerto-lightbox.min.js'))
.pipe(buffer())
.pipe(uglify().on('error', (e) => console.log(e)))
.pipe(gulp.dest('dist'))
})
gulp.task('build', gulp.parallel('build-sass', 'build-js'))
gulp.task('build-watching', () => {
gulp.watch('src/scss/**/*.scss', gulp.series('build-sass'))
gulp.watch('src/js/**/*.js', gulp.series('build-js'))
})
gulp.task('start', gulp.series('build', 'build-watching'))