-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
78 lines (62 loc) · 1.82 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var gutil = require('gulp-util');
var notify = require('gulp-notify');
var browserSync = require('browser-sync').create();
var autoprefixerOptions = {
browsers: ['last 2 versions', '> 5%', 'Firefox ESR']
};
var reportError = function (error) {
notify({
title: 'Gulp Task Error',
message: 'Check the console.'
}).write(error);
console.log(error.toString());
this.emit('end');
}
var input = './src/**/*.scss';
var output = './public/css/';
gulp.task('sass', function() {
return gulp
.src(input)
.pipe(sourcemaps.init())
.pipe(sass())
.on('error', reportError)
.pipe(sourcemaps.write())
.pipe(gulp.dest(output))
.pipe(notify("CSS updated !"));
});
gulp.task('copy-thirdparty', function() {
let files = [
'./bower_components/jquery/dist/jquery.min.js',
'./bower_components/bootstrap/dist/css/bootstrap.min.css',
];
return gulp.src(files, {base: './bower_components'})
.pipe(gulp.dest('./public/thirdparty/'));
});
gulp.task('watch', function() {
return gulp
.watch(input, ['sass'])
.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
gulp.task('prod', [], function () {
return gulp
.src(input)
.pipe(sass({outputStyle: 'compressed' }))
.pipe(autoprefixer(autoprefixerOptions))
.pipe(gulp.dest(output));
});
gulp.task('serve', ['copy-thirdparty'], function() {
browserSync.init({
files: [output, 'public/js/*.js'],
proxy: "http://localhost/react/demo05_author_quiz.html",
});
});
gulp.task('local', ['watch', 'copy-thirdparty'], function(){
});
gulp.task('default', ['watch', 'serve'], function(){
});