Last active
August 29, 2015 14:01
-
-
Save dhoko/d333c6105459c59ff0d9 to your computer and use it in GitHub Desktop.
Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fichier dans le dossier task pour le cas deux | |
var gulp = require('gulp'), | |
concat = require("gulp-concat") | |
es = require('event-stream') | |
partials = require('gulp-partial-to-script') | |
streamqueue = require('streamqueue'); | |
module.exports = function() { | |
"use strict"; | |
return es.merge( | |
gulp.src([ | |
'./src/layout/header.html', | |
'./src/layout/body.html' | |
]), | |
gulp.src('./src/partials/**/*.html').pipe(partials()), | |
gulp.src([ | |
'./src/layout/footer.html', | |
]) | |
) | |
.pipe(concat('index.html')) | |
.pipe(gulp.dest('./build')); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cas d'origine: ça fonctionne parfaitement | |
gulp.watch(["./src/layout/**/*","./src/partials/**/*"], ["templates"]); | |
gulp.task('templates', function() { | |
return es.merge( | |
gulp.src([ | |
'./src/layout/header.html', | |
'./src/layout/body.html' | |
]), | |
gulp.src('./src/partials/**/*.html').pipe(partials()), | |
gulp.src([ | |
'./src/layout/footer.html', | |
]) | |
) | |
.pipe(concat('index.html')) | |
.pipe(gulp.dest('./build')) | |
.pipe(livereload(server)); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cas deux, la task est dans un fichier | |
gulp.watch(["./src/layout/**/*","./src/partials/**/*"], ["templates"]) | |
.on("change", function(file) { | |
livereload(server).changed(file.path); | |
}); | |
gulp.task('templates', require('./tasks/template')); |
Dans ton cas 2 tu as bien ça ?
gulp.task('templates', require('./tasks/template'));
module.exports = function() {
gulp.watch(["./src/layout/**/*","./src/partials/**/*"], ["templates"])
.on("change", function(file) {
livereload(server).changed(file.path);
});
})
}
Négatif mon watch est dans le gulpfile. Je laisse dans le gulpFile que le minimum à savoir, mon serveur + le watch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doc :
J'ai relu la documentation pour vérifier, nop c'est bon.
Je lance gulp mon app se lance donc mes templates sont ok. Au watch ça plante, je dois faire deux fois CTRL S.
es.concat
streamQueue
Rien à faire seule la solution 1 fonctionne comme je le veux. (Je veux le faire sans mettre un
setTimeout
:/ dans le cas deux)