【发布时间】:2026-02-09 18:20:14
【问题描述】:
我正在尝试为 Windows 上的客户端设置 CSS 预处理和浏览器同步。 Prepros 似乎很垃圾,而且他不能使用 codeKit,因为它只有 Mac。
我给了他这些资源:https://webdesign.tutsplus.com/tutorials/supercharge-your-local-wordpress-development--cms-28303 和 https://browsersync.io/docs/gulp
预处理效果很好,但必须手动刷新浏览器才能看到 CSS 更改。
您能发现这段代码中有什么不正确的地方吗? MAMP 也参与其中......所以它可能是别的东西。我正在尝试不同的配置来解决问题。
// gulpfile.js
var gulp = require('gulp');
var browserSync = require('browser-sync');
var stylus = require('gulp-stylus');
gulp.task('setup-server', function() {
var files = [
'./style.css',
'./*.php',
];
browserSync.init(files, {
proxy: 'https://website-name.dev',
});
});
gulp.task('compile-stylus', function () {
return gulp.src('stylus/*.styl')
.pipe( stylus({
// options
}))
.pipe( gulp.dest('./') ) // root of theme
.pipe( browserSync.stream() )
;
});
gulp.task('default', ['setup-server', 'compile-stylus'], function() {
gulp.watch('stylus/**/*.styl', ['compile-stylus']);
});
文件结构
【问题讨论】:
标签: gulp mamp browser-sync gulp-stylus