-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
109 lines (101 loc) · 3.19 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
const gulp = require('gulp');
const data = require('gulp-data');
const rename = require("gulp-rename");
const fs = require('fs');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const sourcemaps = require('gulp-sourcemaps');
const browserSync = require('browser-sync').create();
const nunjucksRender = require('gulp-nunjucks-render');
const postcss = require('gulp-postcss');
const cssnano = require('gulp-cssnano');
const sorting = require('postcss-sorting');
const cssnext = require("postcss-cssnext");
const precss = require('precss');
const spritesmith = require("gulp.spritesmith");
const setting = {
buildPath: './',
projectName: 'uniqa',
cssPath: 'css',
jsPath: 'js',
templatesPath: ['./templates', './sections'],
pagesPath: './templates/pages/',
cssSplitPath: 'css/split/'
};
gulp.task('js', function () {
return gulp.src([
'./js/my-uniqa/jquery-3.2.1.min.js',
'./js/my-uniqa/jquery-ui.js',
'./js/my-uniqa/jquery.validate.min-1.16.0.js',
'./js/my-uniqa/form-validation.js',
'./js/my-uniqa/overall.js',
'./js/my-uniqa/mask.js',
'./js/my-uniqa/jquery.custom-file-input.js',
'./js/my-uniqa/my-uniqa.js'
])
.pipe(concat(setting.projectName + '.js'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(setting.jsPath))
});
gulp.task('css', function() {
return gulp.src([
'./css/sprites/*.css',
'./css/old/*.css',
'./css/new/*.css'
])
.pipe(sourcemaps.init())
.pipe(postcss([
precss(),
cssnext(),
sorting(),
]))
.pipe( cssnano() )
.pipe(concat(setting.projectName + '.css'))
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(setting.cssPath))
});
gulp.task('css-split', function() {
return gulp.src([
'./css/sprites/*.css',
'./css/old/*.css',
'./css/new/*.css'
])
.pipe(sourcemaps.init())
.pipe(postcss([
precss(),
cssnext(),
sorting(),
]))
.pipe(gulp.dest(setting.cssSplitPath))
});
gulp.task('views', function() {
return gulp.src(['./templates/pages/*.html'])
.pipe(nunjucksRender({
path: setting.templatesPath
}))
.pipe(gulp.dest(setting.buildPath));
});
gulp.task('sprites', function () {
return gulp.src('./images/icns/*.png')
.pipe(spritesmith({
imgName: 'sprite-uniqa.png',
cssName: 'sprite-uniqa.css'
}))
.pipe(gulp.dest('./css/sprites/'));
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: './'
},
})
});
gulp.task('dev', ['sprites', 'js', 'css', 'views', 'browserSync', 'css-split'], function() {
gulp.watch('./css/new/*', ['css', 'views', browserSync.reload]);
gulp.watch('./css/old/*', ['css', browserSync.reload]);
gulp.watch('./js/my-uniqa/*.js', ['js', browserSync.reload]);
gulp.watch('./templates/pages/*.html', ['views', browserSync.reload]);
gulp.watch('./templates/components/*.njk', ['views', browserSync.reload]);
gulp.watch('./templates/sections/*.njk', ['views', browserSync.reload]);
});