forked from watchdogpolska/poradnia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (111 loc) · 3.62 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
120
"use strict";
var fs = require('fs'),
gulp = require('gulp'),
sass = require('gulp-sass'),
notify = require("gulp-notify"),
bower = require('gulp-bower'),
watch = require('gulp-watch'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
minifycss = require('gulp-minify-css'),
prefix = require('gulp-autoprefixer'),
livereload = require('gulp-livereload'),
csslint = require('gulp-csslint'),
json = JSON.parse(fs.readFileSync('./package.json'));
var config = (function () {
var appName = json.name;
var path = {
bower: './bower_components/',
npm: './node_modules/',
assets: './' + appName + '/assets',
static: './' + appName + '/static'
};
return {
path: path,
scss: {
input: path.assets + '/scss/style.scss',
include: [
path.bower + '/bootstrap-sass/assets/stylesheets',
path.bower + '/font-awesome/scss',
path.bower + '/pikaday-time/scss/',
path.assets + '/scss/'
],
output: path.static + "/css",
watch: [
path.assets + '/scss/**.scss'
]
},
icons: {
input: [
path.bower + '/font-awesome/fonts/**.*'
],
output: path.static + "/fonts"
},
script: {
input: [
path.bower + '/jquery/dist/jquery.js',
path.bower + '/bootstrap-sass/assets/javascripts/bootstrap/tab.js',
path.bower + '/bootstrap-sass/assets/javascripts/bootstrap/tooltip.js',
path.bower + '/bootstrap-sass/assets/javascripts/bootstrap/modal.js',
path.bower + '/chart.js/dist/Chart.js',
path.bower + '/moment/moment.js',
path.bower + '/moment/locale/pl.js',
path.bower + '/pikaday-time/pikaday.js',
path.npm + '/patternomaly/dist/patternomaly.js',
path.assets + '/js/*.js'
],
output: {
dir: path.static + "/js",
filename: 'script.js'
},
watch: [
path.assets + '/js/*.js'
]
}
};
}());
gulp.task('bower', function () {
return bower(config.path.bower);
});
gulp.task('icons', function () {
return gulp.src(config.icons.input)
.pipe(gulp.dest(config.icons.output));
});
gulp.task('js', function () {
return gulp.src(config.script.input)
.pipe(concat(config.script.output.filename))
.pipe(gulp.dest(config.script.output.dir))
.pipe(livereload())
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(config.script.output.dir))
.pipe(livereload());
});
gulp.task('scss', function () {
return gulp.src(config.scss.input)
.pipe(sass(
{
style: 'expanded',
includePaths: config.scss.include
}
))
.pipe(prefix())
.pipe(gulp.dest(config.scss.output))
.pipe(livereload())
.pipe(rename({extname: '.min.css'}))
.pipe(minifycss())
.pipe(gulp.dest(config.scss.output))
.pipe(livereload());
});
// Rerun the task when a file changes
gulp.task('watch', function () {
livereload.listen();
config.scss.watch.forEach(function (path) {
gulp.watch(path, ['scss']);
});
config.script.watch.forEach(function (path) {
gulp.watch(path, ['js']);
});
});
gulp.task('default', ['bower', 'icons', 'js', 'scss', 'watch']);