-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
75 lines (68 loc) · 2.11 KB
/
gulpfile.js
File metadata and controls
75 lines (68 loc) · 2.11 KB
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
const scssInput = ['scss/style.scss'],
scssOutput = 'app/css',
vendorInput = [
'scripts/vendor/jquery3.1.js',
'scripts/vendor/*.js'
],
jsInput = [
'scripts/domain/*.js'
],
jsOutput = 'app/scripts';
// Start everything up.
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const browserSync = require('browser-sync').create();
const plumber = require('gulp-plumber');
// Watch SASS.
gulp.task('sass', function() {
return gulp
.src(scssInput)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(gulp.dest(scssOutput))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('domainScripts', function() {
return gulp.src(jsInput)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['env']
}))
.pipe(concat('scripts.js'))
.pipe(gulp.dest(jsOutput))
.pipe(rename('scripts.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(jsOutput));
});
gulp.task('vendorScripts', function() {
return gulp.src(vendorInput)
.pipe(plumber())
.pipe(concat('vendor.js'))
.pipe(gulp.dest(jsOutput));
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'app'
},
})
})
gulp.task('watch', ['sass', 'domainScripts', 'vendorScripts', 'browserSync'], function (){
gulp.watch('scss/**/*.scss', ['sass', browserSync.reload]);
gulp.watch('app/**/*.html', browserSync.reload);
gulp.watch('scripts/domain/**/*.js', ['domainScripts', browserSync.reload]);
gulp.watch('scripts/vendor/**/*.js', ['vendorScripts', browserSync.reload]);
});