-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
119 lines (97 loc) · 2.88 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
// production
// var gzip = require('gulp-gzip');
// var runSequence = require('run-sequence');
// scripts
// var concat = require('gulp-concat');
// var uglify = require('gulp-uglify');
// styles
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
var jeet = require('node-jeet-sass').includePaths;
var normalize = require('node-normalize-scss').includePaths
var sass = require('gulp-sass');
// paths
var Root = './';
var appRoot = Root + 'app/';
//var staticRoot = 'static/';
var config = {
'dist': {
'root': Root
},
//'gzip': {
//'src': staticRoot + '**/*.{html,css,js,css.map,js.map}',
//'dest': staticRoot
//},
'templates' : {
'src' : appRoot + '*.html'
//'src' : appRoot + '**/*.html',
//'dest': appRoot + 'scripts/app/'
},
'scripts' : {
'src' : appRoot + 'scripts/*.js'
//'src' : appRoot + 'scripts/app/**/*.js',
//'dest': Root + 'static/'
},
'styles' : {
'src' : appRoot + 'styles/main.sass',
'watch': appRoot + 'styles/**/*',
'dest': Root + 'static/',
}
}
//gulp.task('gzip', function() {
//return gulp.src(config.gzip.src)
//.pipe(gzip({}))
//.pipe(gulp.dest(config.gzip.dest));
//});
gulp.task('styles', function() {
var processors = [
autoprefixer({browsers: ['last 3 versions', '> 1%', 'ie 9']}),
mqpacker({
sort: true
}),
csswring({
preserveHacks: true,
removeAllComments: true
})
];
return gulp.src(config.styles.src)
.pipe(sass({includePaths: [].concat(
normalize,
jeet
)})
.on('error', sass.logError))
.pipe(postcss(processors))
.pipe(gulp.dest(config.styles.dest))
.pipe(browserSync.stream({
once: true
}));
});
gulp.task('sync', ['styles'], function() {
//gulp.task('sync', ['templates', 'scripts', 'styles'], function() {
browserSync.init({
server: config.dist.root,
open: false,
ghostMode: {
clicks: false,
forms: false,
scroll: false
},
notify: false,
logLevel: 'info'
});
gulp.watch(config.templates.src).on('change', browserSync.reload);
gulp.watch(config.scripts.src).on('change', browserSync.reload);
//gulp.watch(config.templates.src, ['templates']);
//gulp.watch(config.scripts.src, ['scripts']);
gulp.watch(config.styles.watch, ['styles']);
});
gulp.task('default', ['sync']);
gulp.task('prod', function() {
//runSequence(['templates', 'styles', 'scripts'], 'gzip');
console.log('Production task already completed!');
});