-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
103 lines (90 loc) · 3.34 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
// JavaScript Document
'use strict';
var gulp = require('gulp'),
//watch = require('gulp-watch'),
prefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
//rigger = require('gulp-rigger'),
cssmin = require('gulp-minify-css'),
//cleanCSS = require('gulp-clean-css'),
//rimraf = require('rimraf'),
//concat = require('gulp-concat'),
//concatCss = require('gulp-concat-css'),
//through2 = require('through2').obj,
changed = require('gulp-changed'),
mkdirp = require('mkdirp'),
plumber = require('gulp-plumber');
gulp.task('style', function () {
gulp.src("src/public/**/*.sass") //Выберем наш main.scss
.pipe(changed("public", {extension: '.css'}))
.pipe(sourcemaps.init())
.pipe(sass()) //Скомпилируем
//.pipe(prefixer()) //Добавим вендорные префиксы
.pipe(cssmin()) //Сожмем
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("public"));
});
gulp.task('css', function () {
gulp.src("src/public/**/*.css")
.pipe(changed("public"))
.pipe(cssmin()) //Сожмем
.pipe(gulp.dest("public"));
});
gulp.task('js', function () {
gulp.src("src/public/**/*.js")
.pipe(plumber())
.pipe(changed("public"))
.pipe(sourcemaps.init())
.pipe(uglify()) //Сожмем наш js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest("public"));
});
//content
gulp.task('content', function () {
gulp.src("src/public/**/*.{jpg,png,gif,svg,otf,eot,svg,ttf,woff,woff2}")
.pipe(changed("public"))
.pipe(gulp.dest("public"));
});
gulp.task('index.html', function () {
gulp.src("src/public/index.html")
.pipe(changed("public"))
.pipe(gulp.dest("public"));
});
mkdirp('public/design-thumbnails', function (err) {
if (err) console.error(err)
else console.log('pow!')
});
/*gulp.task('style:build', function () {
gulp.src(path.src.style) //Выберем наш main.scss
.pipe(sourcemaps.init()) //То же самое что и с js
.pipe(sass()) //Скомпилируем
.pipe(prefixer()) //Добавим вендорные префиксы
.pipe(cssmin()) //Сожмем
.pipe(sourcemaps.write())
.pipe(gulp.dest(path.build.css)) //И в build
.pipe(reload({stream: true}));
});
gulp.task('js:build', function () {
gulp.src(path.src.js) //Найдем наш main файл
.pipe(rigger()) //Прогоним через rigger
.pipe(sourcemaps.init()) //Инициализируем sourcemap
.pipe(uglify()) //Сожмем наш js
.pipe(sourcemaps.write()) //Пропишем карты
.pipe(gulp.dest(path.build.js)) //Выплюнем готовый файл в build
.pipe(reload({stream: true})); //И перезагрузим сервер
});*/
gulp.task('build', [
'index.html',
'style',
'css',
"js",
'content'
]);
gulp.task('default', ['build']);
gulp.watch("src/public/index.html", ['index.html']);
gulp.watch("src/public/**/*.sass", ['style']);
gulp.watch("src/public/**/*.css", ['css']);
gulp.watch("src/public/**/*.js", ['js']);
gulp.watch("src/public/**/*.{jpg,png,gif,svg,otf,eot,svg,ttf,woff,woff2}", ['content']);