Skip to content

Instantly share code, notes, and snippets.

@moog16
Last active March 8, 2017 08:09
Show Gist options
  • Select an option

  • Save moog16/cff5f3e678e2463a0729c626c0cfcd7f to your computer and use it in GitHub Desktop.

Select an option

Save moog16/cff5f3e678e2463a0729c626c0cfcd7f to your computer and use it in GitHub Desktop.
Gulp watch tasks for styles
// I run this right after webpack-dev-server task is complete
gulp.task('watch', () => {
gulp.watch('./styles/**/*.scss', ['watchCss']);
});
// this triggers whenever a `.scss` file changes
// which triggers a new scss compliation
gulp.task('watchCss', ['buildStyles'], () => {
// browserSyncInstance is defined in my above gist
// https://gist.github.com/moog16/095f6e6e592ae83c0182e0977c8a8762
if(!browserSyncInstance) {
return;
}
// find the css file in /static
const file = path.resolve(__dirname, `static/css/${clients[0]}/app.css`);
// source the file and use browserSync to update it, without refreshing the page
// which saves the state of the app
return gulp.src(file)
.pipe(browserSyncInstance.stream());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment