-
Notifications
You must be signed in to change notification settings - Fork 50
/
gulpfile.js
71 lines (63 loc) · 1.56 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var header = require('gulp-header');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var uglify = require('gulp-uglify');
var autoprefixer = require('gulp-autoprefixer');
var pkg = require('./package.json');
// Set the banner content
var banner = ['/*!\n',
' * bootstra-suggest - <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n',
' * Copyright 2013-' + (new Date()).getFullYear(), ' <%= pkg.author %>\n',
' * Licensed under <%= pkg.license %> (https://github.com/lodev09/<%= pkg.name %>/blob/master/LICENSE)\n',
' */\n',
'\n'
].join('');
// Compile and minify SCSS
gulp.task('css', function(done) {
gulp.src('./src/**/*.scss')
.pipe(sass.sync({
outputStyle: 'expanded'
}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('./dist'))
gulp.src([
'./css/*.css',
'!./css/*.min.css'
])
.pipe(cleanCSS())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist'));
done();
});
// JS
gulp.task('js', function(done) {
gulp.src([
'./src/*.js',
'!./src/*.min.js'
])
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest('./dist'));
gulp.src([
'./src/*.js'
])
.pipe(gulp.dest('./dist'))
done();
});
// Default task
gulp.task('default', gulp.parallel('css', 'js'));