-
Notifications
You must be signed in to change notification settings - Fork 36
/
gulpfile.js
94 lines (93 loc) · 3.23 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
"use strict";
var gulp = require('gulp');
var concat = require('gulp-concat');
var source = require('vinyl-source-stream');
var closure = require('gulp-closure-compiler-service');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var gulpif = require('gulp-if');
var sprity = require('sprity');
var csso = require('gulp-csso');
var rename = require('gulp-rename');
var config = {
port: 9005,
devBaseUrl: 'http://localhost',
paths: {
html: './src/*.html',
ssi_uploaderJs: './src/ssi-uploader/js/ssi-uploader.js',
ssi_uploaderSass: './src/ssi-uploader/styles/ssi-uploader.scss',
ssi_uploaderImage: './src/ssi-uploader/styles/images/**/*.{png,jpg}',
dist: './dist'
},
sassOptions: {
errLogToConsole: true,
outputStyle: 'expanded'
}
};
gulp.task('browser-sync', function () {
browserSync.init({
server: {
baseDir: "./dist"
},
ui: {
port: 9090
}
});
});
gulp.task('sprites', function () {
return sprity.src({
src: config.paths.ssi_uploaderImage,
style: './sprite.scss',
cssPath: 'images/',
processor: 'sass'// make sure you have installed sprity-sass
})
.on('error', console.error.bind(console))
.pipe(gulpif('*.png', gulp.dest('./dist/ssi-uploader/styles/images/'), gulp.dest('./src/ssi-uploader/styles/')))
});
gulp.task('html', function () {
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('compile', function () {
gulp.src(config.paths.ssi_uploaderJs)
.pipe(sourcemaps.init())
.pipe(closure()).on('error', console.error.bind(console))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/js/'))
.on('error', console.error.bind(console));
});
gulp.task('js', function () {
gulp.src(config.paths.ssi_uploaderJs)
.on('error', console.error.bind(console))
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/js'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('sass', function () {
gulp.src(config.paths.ssi_uploaderSass)
.pipe(sass(config.sassOptions))
.on('error', console.error.bind(console))
.pipe(autoprefixer())
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/styles'))
.pipe(browserSync.reload({stream: true}))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.init())
.pipe(csso())
.on('error', console.error.bind(console))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/styles'));
});
gulp.task('images', function () {
gulp.src(config.paths.ssi_uploaderImage)
.pipe(gulp.dest(config.paths.dist + '/ssi-uploader/images'));
});
gulp.task('watch', function () {
gulp.watch(config.paths.html, ['html']);
gulp.watch(config.paths.ssi_uploaderJs, ['js']);
gulp.watch(config.paths.ssi_uploaderSass, ['sass']);
gulp.watch(config.paths.ssi_uploaderImage, ['images']);
});
gulp.task('default', ['html', 'sass', 'js', 'browser-sync', 'watch']);