This repository has been archived by the owner on Jul 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
95 lines (85 loc) · 2.43 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Base Gulp File
var gulp = require('gulp'),
sass = require('gulp-sass'),
notify = require('gulp-notify'),
browserSync = require('browser-sync'),
uglify = require('gulp-uglify'),
gulpif = require('gulp-if'),
cleanCSS = require('gulp-clean-css'),
concat = require('gulp-concat'),
runSequence = require('run-sequence'),
rename = require("gulp-rename"),
argv = require('yargs').argv;
var isProduction = argv.production ? true : false,
cssOutputStyle = isProduction ? 'compressed' : 'expanded',
outputDir = './dist',
sourceDir = './src',
sassOutputDir = outputDir+'/css',
jsOutputDir = outputDir+'/js';
var jsSources=[
sourceDir + '/js/*.js',
],
sassSources=[
sourceDir + '/scss/bootstrap-range.scss',
],
htmlSources=[
sourceDir+'/*.html',
];
// Compile SCSS
gulp.task('sass', function () {
return gulp.src(sassSources)
.pipe(sass({
// errLogToConsole: false,
outputStyle: cssOutputStyle,
// paths: [ path.join(__dirname, 'scss', 'includes') ]
})
.on("error", notify.onError(function(error) {
return "Failed to Compile SCSS: " + error.message;
})))
.pipe(gulpif(isProduction, rename({suffix: ".min"})))
.pipe(gulp.dest(sassOutputDir))
.pipe(browserSync.reload({
stream: true
}))
.pipe(notify('Sass sources compiled'));
});
// Copy & minify JS files
gulp.task('js', function() {
return gulp.src(jsSources)
.pipe(gulpif(isProduction, uglify()))
.pipe(gulpif(isProduction, rename({suffix: ".min"})))
.pipe(gulp.dest(jsOutputDir))
.pipe(browserSync.reload({
stream: true
}))
.pipe(notify('JS sources compiled'));
});
// Html preprocess
gulp.task('html', function() {
gulp.src(htmlSources)
.pipe(gulp.dest(outputDir))
.pipe(browserSync.reload({
stream: true
}))
.pipe(notify('Html sources compiled'));
});
// BrowserSync Task (Live reload)
gulp.task('browserSync', function() {
browserSync({
server: {
baseDir: outputDir
}
})
});
// Gulp Watch Task
gulp.task('watch', ['browserSync'], function () {
gulp.watch(sassSources, ['sass']);
gulp.watch(jsSources, ['js']);
gulp.watch(htmlSources,['html']);
});
// Gulp Default Task
gulp.task('default', ['watch']);
// Gulp Build Task
gulp.task('build',[],function () {
runSequence('sass','js','html');
});