shakyShane/jekyll-gulp-sass-browser-sync

Try to add folder with htmls which I want to use with AJAX to the browsersync baseDir

szymonhernik opened this issue · 0 comments

Hello,
I want to add folder with html files which next I want to use with AJAX calls. The only thing I can do is adding these files directly to the project's folder (next to the index.html). I'm guessing I need to do sth with browserSync but I don't know how.

You can see in gulp task watch I've tried to add folder ajax with html files but I can't use them next with ajax call.

My gulpfile.js is:

var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var cp = require('child_process');
var pug = require('gulp-pug');

var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
var messages = {
jekyllBuild: 'Running: $ jekyll build'
};

/**

  • Build the Jekyll Site
    */
    gulp.task('jekyll-build', function (done) {
    browserSync.notify(messages.jekyllBuild);
    return cp.spawn( jekyll , ['build'], {stdio: 'inherit'})
    .on('close', done);
    });

/**

  • Rebuild Jekyll & do page reload
    */
    gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
    browserSync.reload();
    });

/**

  • Wait for jekyll-build, then launch the Server
    */
    gulp.task('browser-sync', ['sass', 'jekyll-build'], function() {
    browserSync({
    server: {
    baseDir: '_site'
    },
    notify: false
    });
    });

/**

  • Compile files from _scss into both _site/css (for live injecting) and site (for future jekyll builds)
    */
    gulp.task('sass', function () {
    return gulp.src('assets/css/main.scss')
    .pipe(sass({
    includePaths: ['css'],
    onError: browserSync.notify
    }))
    .pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
    .pipe(gulp.dest('_site/assets/css'))
    .pipe(browserSync.reload({stream:true}))
    .pipe(gulp.dest('assets/css'));
    });

/*
I'm trying to Gulp stuff
*/

gulp.task('pug', function(){
return gulp.src('_pugfiles/*.pug')
.pipe(pug())
.pipe(gulp.dest('_includes'));
});

/**

  • Watch scss files for changes & recompile
  • Watch html/md files, run jekyll & reload BrowserSync
    /
    gulp.task('watch', function () {
    gulp.watch('assets/css/', ['sass']);
    gulp.watch('assets/js/
    ', ['jekyll-rebuild']);
    gulp.watch(['
    .html', '_layouts/.html', '_includes/', '_ajax/.html'], ['jekyll-rebuild']);
    gulp.watch('_pugfiles/
    .pug', ['pug']);
    });

/**

  • Default task, running just gulp will compile the sass,
  • compile the jekyll site, launch BrowserSync & watch files.
    */
    gulp.task('default', ['browser-sync', 'watch']);