|
| 1 | +var gulp = require('gulp'), |
| 2 | +settings = require('./settings'), |
| 3 | +browserSync = require('browser-sync').create(), |
| 4 | +postcss = require('gulp-postcss'), |
| 5 | +autoprefixer = require('autoprefixer'), |
| 6 | +cssvars = require('postcss-simple-vars'), |
| 7 | +nested = require('postcss-nested'), |
| 8 | +cssImport = require('postcss-import'), |
| 9 | +mixins = require('postcss-mixins') |
| 10 | + |
| 11 | +gulp.task('styles', function() { |
| 12 | + return gulp.src(settings.themeLocation + 'css/style.css') |
| 13 | + .pipe(postcss([cssImport, mixins, cssvars, nested, autoprefixer])) |
| 14 | + .on('error', (error) => console.log(error.toString())) |
| 15 | + .pipe(gulp.dest(settings.themeLocation)); |
| 16 | +}); |
| 17 | + |
| 18 | +gulp.task('watch', function() { |
| 19 | + browserSync.init({ |
| 20 | + notify: false, |
| 21 | + proxy: settings.urlToPreview, |
| 22 | + ghostMode: false |
| 23 | + }); |
| 24 | + |
| 25 | + gulp.watch('./**/*.php', function() { |
| 26 | + browserSync.reload(); |
| 27 | + }); |
| 28 | + gulp.watch(settings.themeLocation + 'css/**/*.css', gulp.series('waitForStyles')); |
| 29 | +}); |
| 30 | + |
| 31 | +gulp.task('waitForStyles', gulp.series('styles', function() { |
| 32 | + return gulp.src(settings.themeLocation + 'style.css') |
| 33 | + .pipe(browserSync.stream()); |
| 34 | +})); |
0 commit comments