Last active
March 8, 2017 08:09
-
-
Save moog16/cff5f3e678e2463a0729c626c0cfcd7f to your computer and use it in GitHub Desktop.
Gulp watch tasks for styles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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