我没有运气来重新加载我的Gulp在Chrome中重新加载页面的运气。我真的很感谢任何人都能提供的帮助。
sass_theme
任务和watch
任务上运行livereload,但是在任务运行时都不会重新加载。这是我的gulp文件的样子:
'use strict';
var theme_name = 'oda';
var theme_path = `./wp-content/themes/${theme_name}`;
var gulp = require('gulp');
var sass = require('gulp-sass');
var cssnano = require('gulp-cssnano');
var autoprefixer = require("gulp-autoprefixer");
var sourcemaps = require('gulp-sourcemaps');
var livereload = require('gulp-livereload');
gulp.task('sass_theme', function () {
return gulp.src(`${theme_path}/assets/scss/theme/*.scss`)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(cssnano())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(`${theme_path}/assets/css/theme/`))
.pipe(livereload());
});
gulp.task('watch', function () {
livereload.listen();
gulp.watch(`${theme_path}/assets/scss/theme/*.scss`, gulp.series('sass_theme'));
});