-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
50 lines (41 loc) · 1.48 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
var theme = 'cafrilosa';
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
concatCss = require('gulp-concat-css'),
CleanCSS = require('clean-css'),
map = require('vinyl-map'),
concatJs = require('gulp-concat'),
uglify = require('gulp-uglify'),
server = require('gulp-express'),
env = require('gulp-env');
gulp.task('sass', function () {
var minify = map(function (buff, filename) {
return new CleanCSS({
}).minify(buff.toString()).styles;
});
return gulp.src('content/themes/' + theme + '/lib/stylesheets/components.sass')
.pipe(sass({optionStyle: "compressed"}).on('error', sass.logError))
.pipe(concatCss('components.css'))
.pipe(autoprefixer({
cascade: true
}))
.pipe(minify)
.pipe(gulp.dest('content/themes/' + theme + '/assets/css/'));
});
gulp.task('minify:js', function() {
return gulp.src('content/themes/' + theme + '/lib/js/*.js')
.pipe(uglify())
.pipe(concatJs('app.js'))
.pipe(gulp.dest('content/themes/' + theme + '/assets/js/min/'));
});
gulp.task('server', function () {
env({file: '.env'});
var serverOptions = {
env: process.env
};
server.run(['index.js'], serverOptions, false);
gulp.watch('content/themes/' + theme + '/lib/stylesheets/**/*.sass', ['sass']);
gulp.watch('content/themes/' + theme + '/lib/js/**/*.js', ['minify:js']);
});
gulp.task('default', ['server']);