-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
99 lines (91 loc) · 2.45 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
96
97
98
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var header = require('gulp-header');
var pkg = require('./package.json');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var cleancss = require('gulp-clean-css');
var postcss = require('gulp-postcss');
var rgba = require('postcss-background-rgba');
var colorRgba = require("postcss-color-rgba-fallback");
var browserSync = require('browser-sync').create();
var config = {
src: {
css: './src/sass/alerty.scss',
js: './src/scripts/alerty.js'
},
dist: {
css: './dist/css',
js: './dist/js',
js: './'
},
autoprefix: {
browsers: [
'Android 2.3',
'Android >= 4',
'Chrome >= 35',
'Firefox >= 31',
'Explorer >= 8',
'iOS >= 7',
'Opera >= 12',
'Safari >= 7.1'
],
cascade: false
},
ie8fix:[
rgba,
colorRgba({
properties:["color", "border", "border-color"]
})
],
uglify: {
mangle: true,
compress: true
},
banner: [
'/*!',
' * <%= pkg.name %> v<%= pkg.version %> (<%= pkg.homepage %>)',
' * Copyright <%= new Date().getFullYear() %> <%= pkg.author %>',
' * Licensed under the <%= pkg.license %> license',
' */',
''].join('\n')
};
gulp.task('sass', function() {
gulp.src(config.src.css)
.pipe(sass({outputStyle:'expanded'}).on('error', sass.logError))
.pipe(autoprefixer(config.autoprefix))
.pipe(postcss(config.ie8fix))
.pipe(header(config.banner, { pkg : pkg } ))
.pipe(gulp.dest(config.dist.css))
.pipe(cleancss({compatibility: 'ie8'}))
.pipe(rename({suffix: '.min' }))
.pipe(gulp.dest(config.dist.css));
});
gulp.task('js', function() {
gulp.src(config.src.js)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(header(config.banner, { pkg : pkg } ))
.pipe(gulp.dest(config.dist.js))
.pipe(uglify(config.uglify))
.pipe(header(config.banner, { pkg : pkg } ))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(config.dist.js));
});
gulp.task('watch',['sass', 'js'], function() {
gulp.watch('./src/sass/**/*.scss', ['sass']);
gulp.watch(config.src.js, ['js']);
});
gulp.task('server', function() {
browserSync.init({
files: ['./dist/**','./example/*.html'],
port: '8888',
server: {
baseDir: ['dist', 'example']
}
})
});
gulp.task('default',['sass', 'js', 'watch', 'server']);