SCSS和JS文件的工作方式和以前一样,但当我保存.php文件时,它会重新加载浏览器,但不会更新HTML。
这是我的gulpfile.js
我试着分离手表功能,并试图添加一些延迟,但没有成功
const gulp = require('gulp');
const { src, dest, watch, series } = require('gulp');
// styles
const scss = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const cssMinify = require('gulp-clean-css');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
function styles(){
return src([
'./wp-content/themes/savez-tema/src/scss/vendor/_bootstrap.min.scss',
'./wp-content/themes/savez-tema/src/scss/**/*.scss'
])
.pipe( scss() )
.pipe( autoprefixer('last 2 versions') )
.pipe( cssMinify() )
.pipe( dest('./wp-content/themes/savez-tema/dist/css'))
.pipe(browserSync.stream());
}
// scripts
const jsMinify = require('gulp-terser');
function scripts(){
return src ([
'./wp-content/themes/savez-tema/src/js/vendor/bootstrap.min.js',
'./wp-content/themes/savez-tema/src/js/**/*.js'
])
.pipe(concat('main.js'))
.pipe( jsMinify() )
.pipe( dest('./wp-content/themes/savez-tema/dist/js'))
.pipe(browserSync.reload({stream: true})); // proveri
}
// watch
function watchTask(){
browserSync.init({
proxy: 'http://localhost:8888/savez',
});
watch(['./wp-content/themes/savez-tema/**/*.php', './wp-content/themes/savez-tema/src/scss/**/*.scss', './wp-content/themes/savez-tema/src/js/**/*.js'],
series(styles, scripts))
}
exports.default = series(styles, scripts, watchTask)
字符串
1条答案
按热度按时间j2cgzkjk1#
在花了很多时间尝试不同的aproaches这里是工作解决方案:
P.S -如果使用MAMP禁用PHP缓存这是必须的!
字符串