forked from watchdogpolska/poradnia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
125 lines (115 loc) · 3.94 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
121
122
123
124
125
"use strict";
var fs = require('fs'),
gulp = require('gulp'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'),
minifycss = require('gulp-minify-css'),
prefix = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
watch = require('gulp-watch'),
json = JSON.parse(fs.readFileSync('./package.json'));
var config = (function () {
var appName = json.name;
var path = {
npm: './node_modules/',
app: './' + appName,
assets: './' + appName + '/assets',
static: './' + appName + '/static',
staticfiles: './staticfiles'
};
return {
path: path,
scss: {
input: path.assets + '/scss/style.scss',
include: [
path.npm,
path.npm + '/pikaday-time/scss/',
path.staticfiles,
path.assets + '/scss/'
],
output: path.static + "/css",
watch: [
path.assets + '/scss/**.scss'
]
},
icons: {
input: [
path.npm + '/font-awesome/fonts/**.*'
],
output: path.static + "/fonts"
},
script: {
input: [
path.npm + '/jquery/dist/jquery.js',
path.npm + '/bootstrap-sass/assets/javascripts/bootstrap/tab.js',
path.npm + '/bootstrap-sass/assets/javascripts/bootstrap/tooltip.js',
path.npm + '/bootstrap-sass/assets/javascripts/bootstrap/modal.js',
path.staticfiles + '/autocomplete_light/vendor/select2/dist/js/select2.full.js',
path.staticfiles + '/autocomplete_light/jquery.init.js',
path.staticfiles + '/autocomplete_light/autocomplete.init.js',
path.staticfiles + '/autocomplete_light/forward.js',
path.staticfiles + '/autocomplete_light/select2.js',
path.staticfiles + '/tasty_feedback/style.js',
path.npm + '/chart.js/dist/Chart.js',
path.npm + '/moment/moment.js',
path.npm + '/moment/locale/pl.js',
path.npm + '/pikaday-time/pikaday.js',
path.npm + '/patternomaly/dist/patternomaly.js',
path.assets + '/js/*.js',
path.app + '/navsearch/static/navsearch/*.js',
],
output: {
dir: path.static + "/js",
filename: 'script.js'
},
watch: [
path.assets + '/js/*.js'
]
}
};
}());
console.log(config.script);
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('build', ['icons', 'js', 'scss']);
gulp.task('default', ['build', 'watch']);