Monday, 13 March 2017

Temporarily add script on page using gulp

I'm currently working on a gulp project and I have this gulpfile.js

var config = require('./config.json'),
    gulp = require('gulp'),
    watch = require('gulp-watch'),
    connect = require('gulp-connect'),
    runSequence = require('run-sequence');

gulp.task('server', function() {
    connect.server({
        root: './',
        port: config.port,
        livereload: true
    });
});

gulp.task('html', function() {
    gulp.src('./' + config.creatives + '/**/*.html')
        .pipe(connect.reload());
});

gulp.task('watch', function() {
    gulp.watch(['./' + config.creatives + '/**/*.html'], ['html']);
    gulp.watch(['./' + config.creatives + '/**/*.css'], ['html']);
});

gulp.task('default', function() {
    return runSequence('server', ['html', 'watch']);
});

the config.json content is

{
    "port" : "2727",
    "creatives" : "creatives"
}

My question is how can I add a temporary script file to the page I'm currently viewing? I saw connect-livereload is adding livereload.js on the bottom of my page & I would like to do the same. Thanks in advance.



via Neo Genesis

No comments:

Post a Comment