-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathgulpfile.js
78 lines (62 loc) · 1.81 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
//Import dependencies
var autoprefixer = require('gulp-autoprefixer');
var fs = require('fs');
var gulp = require('gulp');
var concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
var rename = require('gulp-rename');
var header = require('gulp-header');
var sass = require('gulp-sass');
var del = require('del');
//Import the package
var pkg = require('./package.json');
//Banner structure
var banner = []
banner.push('/**');
banner.push(' * <%= pkg.name %> - <%= pkg.description %>');
banner.push(' * @version v<%= pkg.version %>');
banner.push(' * @link <%= pkg.homepage %>');
banner.push(' * @license <%= pkg.license %>');
banner.push('**/');
banner.push(' ');
banner.push(' ');
//Join the banner
banner = banner.join('\n');
//Clean the dist folder
gulp.task('clean', function()
{
//Clean the dist folder
return del.sync([ './dist/**' ]);
});
//Build the SCSS files
gulp.task('build:scss', function()
{
//Select all the SCSS files
gulp.src('scss/**/*.scss')
//Build the scss files
.pipe(sass({ includePaths: [ 'bower_components', 'node_modules' ] }).on('error', sass.logError))
//Autoprefix
.pipe(autoprefixer({ browsers: ['last 3 versions', 'IE 9'], cascade: false }))
//Add the header
.pipe(header(banner, { pkg : pkg } ))
//Save on the dist folder
.pipe(gulp.dest('./dist/'));
});
//Minimize the css
gulp.task('minimize', function()
{
//Set the source file
gulp.src('dist/*.css')
//Clean the css
.pipe(cleanCSS({ compatibility: '*', processImportFrom: ['!fonts.googleapis.com'] }))
//Rename the file
.pipe(rename({ extname: '.min.css' }))
//Add the header
.pipe(header(banner, { pkg : pkg } ))
//Save on the dist folder
.pipe(gulp.dest('dist/'));
});
//Build task
gulp.task('build', [ 'build:scss' ]);
//Execute the tasks
gulp.task('default', [ 'clean', 'build' ]);