-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
81 lines (70 loc) · 2.12 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
// Requis
var gulp = require('gulp'),
cssbeautify = require('gulp-cssbeautify'),
inlineCss = require('gulp-inline-css');
var sass = require('gulp-sass');
var csscomb = require('gulp-csscomb');
const autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');
var extender = require('gulp-html-extend');
var del = require('del');
var gulpRemoveHtml = require('gulp-remove-html');
var runSequence = require('run-sequence');
// Include plugins
var plugins = require('gulp-load-plugins')();
// Variables de chemins
var source = './app'; // dossier de travail
var destination = './dist'; // dossier à livrer
// les tâches
gulp.task('sass', function(){
return gulp.src(source + '/scss/**/*.scss')
.pipe(plugins.sass())
.pipe(sass()) // Converts Sass to CSS with gulp-sass
.pipe(plugins.csscomb())
.pipe(plugins.cssbeautify({indent: ' '}))
.pipe(plugins.autoprefixer())
.pipe(inlineCss({
applyStyleTags: true,
applyLinkTags: true,
removeStyleTags: true,
removeLinkTags: true
}))
.pipe(gulp.dest(source + '/css'))
});
/*gulp.task('minify', function () {
return gulp.src(destination + '/css/*.css')
.pipe(plugins.csso())
.pipe(plugins.rename({
suffix: '.min'
}))
.pipe(gulp.dest(destination + '/css/'));
});*/
// fusion des includes en un seul fichier
gulp.task('html', function() {
return gulp.src(source + '/{,blocks/}*.html')
// Generates HTML includes
.pipe(extender({
annotations: true,
verbose: true
}))
.pipe(gulp.dest(destination))
});
gulp.task('remove-html', function () {
return gulp.src(source + '/index.html')
.pipe(gulpRemoveHtml())
.pipe(gulp.dest(destination + '/index.txt'));
});
gulp.task('final', function (callback) {
runSequence('inliner', 'html',
callback
)
})
gulp.task('inliner', function() {
return gulp.src(source + '/*.html')
.pipe(inlineCss())
.pipe(gulp.dest(source));
});
// suppression du dossier distribution (dist)
gulp.task('clean', function() {
del(destination);
})