Skip to content

Instantly share code, notes, and snippets.

@mikaa123
Created May 22, 2014 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaa123/0a30004d12af4df66eb5 to your computer and use it in GitHub Desktop.
Save mikaa123/0a30004d12af4df66eb5 to your computer and use it in GitHub Desktop.
Gulp xsl reload
var gulp = require('gulp'),
gutil = require('gulp-util'),
spawn = require('child_process').spawn,
livereload = require('gulp-livereload')
replace = require('gulp-replace');
gulp.task('staticsvr', function(next) {
var staticS = require('node-static'),
server = new staticS.Server('./'),
port = 2888;
require('http').createServer(function (request, response) {
request.addListener('end', function () {
server.serve(request, response);
}).resume();
}).listen(port, function() {
gutil.log('Server listening on port: ' + gutil.colors.magenta(port));
next();
});
});
gulp.task('watch', ['staticsvr'], function() {
var server = livereload();
gulp.watch(['*.js', '*.css', '*.xml', '*.xsl']).on('change', function(file) {
var child = spawn("xslty", ["input.xml adminViewSupervisorTracking.xsl > result.html"], {cwd: process.cwd()});
child.on('close', function () {
gutil.log('done transforming xml');
server.changed(file.path);
});
});
});
gulp.task('build', function(){
gulp.src(['adminViewSupervisorTracking.xsl'])
.pipe(replace(/http\:\/\/192.168.10.57:8080/g, ''))
.pipe(gulp.dest('build'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment