duanpu4143 2019-03-16 20:59
浏览 46

在Wordpress中更改PHP后,BrowserSync不会显示新样式

I am working on a local wordpress installation.

After I make changes to my CSS file the browser will show them correctly. However, any change in PHP files will revert the styles back to the state before the last change in my CSS was made, forcing me to go back to any CSS file to save it again allowing me to watch both changes made correctly.

Edit: terminal shows 'Reloading Browsers...' as last message everytime I make a change to a PHP file, whereas the CSS task seems to start and end everytime. In the Gulp documentation, I found the following: 'There is no error or warning message provided because the file watcher keeps your Node process running. Since the process doesn't exit, it cannot be determined whether the task is done or just taking a really, really long time to run. ' under the 'Warning: Avoid Synchronous' title but I don't know if this is relevant to my problem.

Edit #2: my problem seems to persist in Chrome. However, in Firefox the behavior is the expected. I work with a disabled cache in Chrome.

I am using a very simple gulpfile.js file.

const gulp = require('gulp'); 
const browsersync = require('browser-sync').create(); 
const postcss = require('gulp-postcss'); 
const cssImport = require('postcss-import'); 
const postcssVariables = require('postcss-simple-vars'); 
const autoprefixer = require('autoprefixer'); 
const { series, parallel } = require('gulp'); 

const stylePath = "./wordpress/wp-content/themes/Produccion/styleFolders/style.css"; 
const styleDest = "./wordpress/wp-content/themes/Produccion/"; 

// BrowserSync function
function browserSync(done) {
  browsersync.init({
    proxy: 'localhost/Produccion/wordpress',
    notify: false
  }); 
  done(); 
}

// Reload function
function reload(done) {
  browsersync.reload(); 
  done(); 
}

function css() {
  return gulp.src(stylePath)
  .pipe(postcss([cssImport, postcssVariables, autoprefixer]))
  .pipe(gulp.dest(styleDest))
  .pipe(browsersync.stream()); 
}

function watchFiles(done) {
  gulp.watch("./wordpress/wp-content/themes/Produccion/styleFolders/**/*.css", css);
  gulp.watch("./wordpress/wp-content/themes/Produccion/**/*.php", reload);
  done(); 
}

const build = gulp.series(browserSync, watchFiles); 
exports.default = build; 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题