2
votes

Hi i have a web site setup. however i cannot get jekyll to compile the actual changes i make in sass files into css file for each article post.

Do i have to add something to my gulp file? I thought jekyll would compile the sass styling into css automatically without need to implement it into gulp? or package.json?

I get sass to work and compile for website layout css folder with gulp command, but the articles section and posts, nothing happens when i change the sass style file for each individual articles, i have to edit the actual css file directly to see a change.

I am missing something here is my code

{
  "name": "browser-sync-jekyll",
  "version": "0.0.0",
  "description": "A starter project including full setup for Jekyll, GulpJS, SASS & BrowserSync",
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Shane Osbourne",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.8.0",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^2.3.1",
    "gulp-jade": "^1.0.1",
    "gulp-sass": "^2.0.4"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/shakyShane/jekyll-gulp-sass-browser-sync.git"
  },
  "keywords": [
    "jekyll",
    "gulp",
    "sass",
    "browsersync"
  ],
  "bugs": {
    "url": "https://github.com/shakyShane/jekyll-gulp-sass-browser-sync/issues"
  },
  "homepage": "https://github.com/shakyShane/jekyll-gulp-sass-browser-sync"
}



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 jade        = require('gulp-jade');

var messages = {
    jekyllBuild: '<span style="color: grey">Running:</span> $ 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'));
});


gulp.task('jade', function(){
  return gulp.src('_jadefiles/*.jade')
  .pipe(jade())
  .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(['index.html', '_layouts/*.html', '_includes/*'], ['jekyll-rebuild']);
    gulp.watch(['assets/js/**'], ['jekyll-rebuild']);
    gulp.watch('_jadefiles/*.jade', ['jade']);
});




/**
 * Default task, running just `gulp` will compile the sass,
 * compile the jekyll site, launch BrowserSync & watch files.
 */
gulp.task('default', ['browser-sync', 'watch']);
1
so under gulp tasks i thought a jekyll rebuild would trigger sass for jekyll posts assets to rebuild css ? is this correct? or does it also need to be inserted into the gulp process separately? sorry for any confusions, i did search around a lot and no one address this technical aspect directly. - frog
You don't need gulp to manage sass, Jekyll does it very well out of the box. Why gulp ? - David Jacquel
That is what i thought. But IF i change Sass file style for article and do Jekyll build. And arter that gulp. It dont write to css. Eg nothing happens. - frog

1 Answers

1
votes

Try Jekyll clean command so that all files can be regerated, ensure that incremental is switched off.